Lines Matching refs:go

33 int go7007_read_interrupt(struct go7007 *go, u16 *value, u16 *data)  in go7007_read_interrupt()  argument
35 go->interrupt_available = 0; in go7007_read_interrupt()
36 go->hpi_ops->read_interrupt(go); in go7007_read_interrupt()
37 if (wait_event_timeout(go->interrupt_waitq, in go7007_read_interrupt()
38 go->interrupt_available, 5*HZ) < 0) { in go7007_read_interrupt()
39 v4l2_err(&go->v4l2_dev, "timeout waiting for read interrupt\n"); in go7007_read_interrupt()
42 if (!go->interrupt_available) in go7007_read_interrupt()
44 go->interrupt_available = 0; in go7007_read_interrupt()
45 *value = go->interrupt_value & 0xfffe; in go7007_read_interrupt()
46 *data = go->interrupt_data; in go7007_read_interrupt()
56 int go7007_read_addr(struct go7007 *go, u16 addr, u16 *data) in go7007_read_addr() argument
61 if (go7007_write_interrupt(go, 0x0010, addr) < 0) in go7007_read_addr()
64 if (go7007_read_interrupt(go, &value, data) == 0 && in go7007_read_addr()
78 static int go7007_load_encoder(struct go7007 *go) in go7007_load_encoder() argument
86 if (go->boot_fw == NULL) { in go7007_load_encoder()
87 if (request_firmware(&fw_entry, fw_name, go->dev)) { in go7007_load_encoder()
88 v4l2_err(go, "unable to load firmware from file \"%s\"\n", fw_name); in go7007_load_encoder()
92 v4l2_err(go, "file \"%s\" does not appear to be go7007 firmware\n", fw_name); in go7007_load_encoder()
99 v4l2_err(go, "unable to allocate %d bytes for firmware transfer\n", fw_len); in go7007_load_encoder()
104 go->boot_fw_len = fw_len; in go7007_load_encoder()
105 go->boot_fw = bounce; in go7007_load_encoder()
107 if (go7007_interface_reset(go) < 0 || in go7007_load_encoder()
108 go7007_send_firmware(go, go->boot_fw, go->boot_fw_len) < 0 || in go7007_load_encoder()
109 go7007_read_interrupt(go, &intr_val, &intr_data) < 0 || in go7007_load_encoder()
111 v4l2_err(go, "error transferring firmware\n"); in go7007_load_encoder()
126 int go7007_boot_encoder(struct go7007 *go, int init_i2c) in go7007_boot_encoder() argument
130 mutex_lock(&go->hw_lock); in go7007_boot_encoder()
131 ret = go7007_load_encoder(go); in go7007_boot_encoder()
132 mutex_unlock(&go->hw_lock); in go7007_boot_encoder()
137 if (go7007_i2c_init(go) < 0) in go7007_boot_encoder()
139 go->i2c_adapter_online = 1; in go7007_boot_encoder()
151 static int go7007_init_encoder(struct go7007 *go) in go7007_init_encoder() argument
153 if (go->board_info->audio_flags & GO7007_AUDIO_I2S_MASTER) { in go7007_init_encoder()
154 go7007_write_addr(go, 0x1000, 0x0811); in go7007_init_encoder()
155 go7007_write_addr(go, 0x1000, 0x0c11); in go7007_init_encoder()
157 switch (go->board_id) { in go7007_init_encoder()
160 go7007_write_addr(go, 0x3c82, 0x0001); in go7007_init_encoder()
161 go7007_write_addr(go, 0x3c80, 0x00fe); in go7007_init_encoder()
165 go7007_write_addr(go, 0x3c82, 0x0000); in go7007_init_encoder()
166 go7007_write_addr(go, 0x3c80, 0x00df); in go7007_init_encoder()
172 go7007_write_addr(go, 0x3c82, 0x000d); in go7007_init_encoder()
173 go7007_write_addr(go, 0x3c80, 0x00f2); in go7007_init_encoder()
185 int go7007_reset_encoder(struct go7007 *go) in go7007_reset_encoder() argument
187 if (go7007_load_encoder(go) < 0) in go7007_reset_encoder()
189 return go7007_init_encoder(go); in go7007_reset_encoder()
197 struct go7007 *go = i2c_get_adapdata(adapter); in init_i2c_module() local
198 struct v4l2_device *v4l2_dev = &go->v4l2_dev; in init_i2c_module()
210 go->sd_video = sd; in init_i2c_module()
212 go->sd_audio = sd; in init_i2c_module()
227 struct go7007 *go = container_of(v4l2_dev, struct go7007, v4l2_dev); in go7007_remove() local
230 if (go->hpi_ops->release) in go7007_remove()
231 go->hpi_ops->release(go); in go7007_remove()
232 if (go->i2c_adapter_online) { in go7007_remove()
233 i2c_del_adapter(&go->i2c_adapter); in go7007_remove()
234 go->i2c_adapter_online = 0; in go7007_remove()
237 kfree(go->boot_fw); in go7007_remove()
238 go7007_v4l2_remove(go); in go7007_remove()
239 kfree(go); in go7007_remove()
250 int go7007_register_encoder(struct go7007 *go, unsigned num_i2c_devs) in go7007_register_encoder() argument
254 dev_info(go->dev, "go7007: registering new %s\n", go->name); in go7007_register_encoder()
256 go->v4l2_dev.release = go7007_remove; in go7007_register_encoder()
257 ret = v4l2_device_register(go->dev, &go->v4l2_dev); in go7007_register_encoder()
261 mutex_lock(&go->hw_lock); in go7007_register_encoder()
262 ret = go7007_init_encoder(go); in go7007_register_encoder()
263 mutex_unlock(&go->hw_lock); in go7007_register_encoder()
267 ret = go7007_v4l2_ctrl_init(go); in go7007_register_encoder()
271 if (!go->i2c_adapter_online && in go7007_register_encoder()
272 go->board_info->flags & GO7007_BOARD_USE_ONBOARD_I2C) { in go7007_register_encoder()
273 ret = go7007_i2c_init(go); in go7007_register_encoder()
276 go->i2c_adapter_online = 1; in go7007_register_encoder()
278 if (go->i2c_adapter_online) { in go7007_register_encoder()
279 if (go->board_id == GO7007_BOARDID_ADS_USBAV_709) { in go7007_register_encoder()
281 go7007_write_addr(go, 0x3c82, 0x0009); in go7007_register_encoder()
283 go7007_write_addr(go, 0x3c82, 0x000d); in go7007_register_encoder()
286 init_i2c_module(&go->i2c_adapter, &go->board_info->i2c_devs[i]); in go7007_register_encoder()
288 if (go->tuner_type >= 0) { in go7007_register_encoder()
291 .type = go->tuner_type, in go7007_register_encoder()
295 v4l2_device_call_all(&go->v4l2_dev, 0, tuner, in go7007_register_encoder()
298 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) in go7007_register_encoder()
299 v4l2_subdev_call(go->sd_video, video, s_routing, in go7007_register_encoder()
300 0, 0, go->channel_number + 1); in go7007_register_encoder()
303 ret = go7007_v4l2_init(go); in go7007_register_encoder()
307 if (go->board_info->flags & GO7007_BOARD_HAS_AUDIO) { in go7007_register_encoder()
308 go->audio_enabled = 1; in go7007_register_encoder()
309 go7007_snd_init(go); in go7007_register_encoder()
321 int go7007_start_encoder(struct go7007 *go) in go7007_start_encoder() argument
327 go->modet_enable = 0; in go7007_start_encoder()
329 go->modet[i].enable = 0; in go7007_start_encoder()
331 switch (v4l2_ctrl_g_ctrl(go->modet_mode)) { in go7007_start_encoder()
333 memset(go->modet_map, 0, sizeof(go->modet_map)); in go7007_start_encoder()
334 go->modet[0].enable = 1; in go7007_start_encoder()
335 go->modet_enable = 1; in go7007_start_encoder()
338 for (y = 0; y < go->height / 16; y++) { in go7007_start_encoder()
339 for (x = 0; x < go->width / 16; x++) { in go7007_start_encoder()
340 int idx = y * go->width / 16 + x; in go7007_start_encoder()
342 go->modet[go->modet_map[idx]].enable = 1; in go7007_start_encoder()
345 go->modet_enable = 1; in go7007_start_encoder()
349 if (go->dvd_mode) in go7007_start_encoder()
350 go->modet_enable = 0; in go7007_start_encoder()
352 if (go7007_construct_fw_image(go, &fw, &fw_len) < 0) in go7007_start_encoder()
355 if (go7007_send_firmware(go, fw, fw_len) < 0 || in go7007_start_encoder()
356 go7007_read_interrupt(go, &intr_val, &intr_data) < 0) { in go7007_start_encoder()
357 v4l2_err(&go->v4l2_dev, "error transferring firmware\n"); in go7007_start_encoder()
362 go->state = STATE_DATA; in go7007_start_encoder()
363 go->parse_length = 0; in go7007_start_encoder()
364 go->seen_frame = 0; in go7007_start_encoder()
365 if (go7007_stream_start(go) < 0) { in go7007_start_encoder()
366 v4l2_err(&go->v4l2_dev, "error starting stream transfer\n"); in go7007_start_encoder()
388 static void go7007_set_motion_regions(struct go7007 *go, struct go7007_buffer *vb, in go7007_set_motion_regions() argument
391 if (motion_regions != go->modet_event_status) { in go7007_set_motion_regions()
401 v4l2_event_queue(&go->vdev, &ev); in go7007_set_motion_regions()
402 go->modet_event_status = motion_regions; in go7007_set_motion_regions()
410 static void go7007_motion_regions(struct go7007 *go, struct go7007_buffer *vb) in go7007_motion_regions() argument
415 unsigned stride = (go->width + 7) >> 3; in go7007_motion_regions()
420 store_byte(vb, go->active_map[i]); in go7007_motion_regions()
421 for (y = 0; y < go->height / 16; y++) { in go7007_motion_regions()
422 for (x = 0; x < go->width / 16; x++) { in go7007_motion_regions()
423 if (!(go->active_map[y * stride + (x >> 3)] & (1 << (x & 7)))) in go7007_motion_regions()
425 motion[go->modet_map[y * (go->width / 16) + x]]++; in go7007_motion_regions()
433 go7007_set_motion_regions(go, vb, motion_regions); in go7007_motion_regions()
439 static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buffer *vb) in frame_boundary() argument
446 spin_lock_irqsave(&go->spinlock, flags); in frame_boundary()
447 if (!list_empty(&go->vidq_active)) in frame_boundary()
448 vb = go->active_buf = in frame_boundary()
449 list_first_entry(&go->vidq_active, struct go7007_buffer, list); in frame_boundary()
450 spin_unlock_irqrestore(&go->spinlock, flags); in frame_boundary()
451 go->next_seq++; in frame_boundary()
456 vb->vb.sequence = go->next_seq++; in frame_boundary()
458 go7007_motion_regions(go, vb); in frame_boundary()
460 go7007_set_motion_regions(go, vb, 0); in frame_boundary()
464 spin_lock_irqsave(&go->spinlock, flags); in frame_boundary()
466 if (list_empty(&go->vidq_active)) in frame_boundary()
469 vb = list_first_entry(&go->vidq_active, in frame_boundary()
471 go->active_buf = vb; in frame_boundary()
472 spin_unlock_irqrestore(&go->spinlock, flags); in frame_boundary()
477 static void write_bitmap_word(struct go7007 *go) in write_bitmap_word() argument
479 int x, y, i, stride = ((go->width >> 4) + 7) >> 3; in write_bitmap_word()
482 y = (((go->parse_length - 1) << 3) + i) / (go->width >> 4); in write_bitmap_word()
483 x = (((go->parse_length - 1) << 3) + i) % (go->width >> 4); in write_bitmap_word()
484 if (stride * y + (x >> 3) < sizeof(go->active_map)) in write_bitmap_word()
485 go->active_map[stride * y + (x >> 3)] |= in write_bitmap_word()
486 (go->modet_word & 1) << (x & 0x7); in write_bitmap_word()
487 go->modet_word >>= 1; in write_bitmap_word()
496 void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length) in go7007_parse_video_stream() argument
498 struct go7007_buffer *vb = go->active_buf; in go7007_parse_video_stream()
501 switch (go->format) { in go7007_parse_video_stream()
518 v4l2_info(&go->v4l2_dev, "dropping oversized frame\n"); in go7007_parse_video_stream()
522 vb = go->active_buf = NULL; in go7007_parse_video_stream()
525 switch (go->state) { in go7007_parse_video_stream()
529 go->state = STATE_00; in go7007_parse_video_stream()
532 go->state = STATE_FF; in go7007_parse_video_stream()
542 go->state = STATE_00_00; in go7007_parse_video_stream()
546 go->state = STATE_FF; in go7007_parse_video_stream()
551 go->state = STATE_DATA; in go7007_parse_video_stream()
562 go->state = STATE_00_00_01; in go7007_parse_video_stream()
567 go->state = STATE_FF; in go7007_parse_video_stream()
573 go->state = STATE_DATA; in go7007_parse_video_stream()
578 if (buf[i] == 0xF8 && go->modet_enable == 0) { in go7007_parse_video_stream()
584 go->state = STATE_DATA; in go7007_parse_video_stream()
589 if ((go->format == V4L2_PIX_FMT_MPEG1 || in go7007_parse_video_stream()
590 go->format == V4L2_PIX_FMT_MPEG2 || in go7007_parse_video_stream()
591 go->format == V4L2_PIX_FMT_MPEG4) && in go7007_parse_video_stream()
595 if (vb == NULL || go->seen_frame) in go7007_parse_video_stream()
596 vb = frame_boundary(go, vb); in go7007_parse_video_stream()
597 go->seen_frame = buf[i] == frame_start_code; in go7007_parse_video_stream()
598 if (vb && go->seen_frame) in go7007_parse_video_stream()
606 go->parse_length = 12; in go7007_parse_video_stream()
607 go->state = STATE_UNPARSED; in go7007_parse_video_stream()
610 go->state = STATE_VBI_LEN_A; in go7007_parse_video_stream()
613 go->parse_length = 0; in go7007_parse_video_stream()
614 memset(go->active_map, 0, in go7007_parse_video_stream()
615 sizeof(go->active_map)); in go7007_parse_video_stream()
616 go->state = STATE_MODET_MAP; in go7007_parse_video_stream()
622 go->state = STATE_FF; in go7007_parse_video_stream()
629 go->state = STATE_DATA; in go7007_parse_video_stream()
637 go->state = STATE_00; in go7007_parse_video_stream()
644 if (go->format == V4L2_PIX_FMT_MJPEG) in go7007_parse_video_stream()
645 vb = frame_boundary(go, vb); in go7007_parse_video_stream()
650 go->state = STATE_DATA; in go7007_parse_video_stream()
655 go->parse_length = buf[i] << 8; in go7007_parse_video_stream()
656 go->state = STATE_VBI_LEN_B; in go7007_parse_video_stream()
659 go->parse_length |= buf[i]; in go7007_parse_video_stream()
660 if (go->parse_length > 0) in go7007_parse_video_stream()
661 go->state = STATE_UNPARSED; in go7007_parse_video_stream()
663 go->state = STATE_DATA; in go7007_parse_video_stream()
666 if (go->parse_length < 204) { in go7007_parse_video_stream()
667 if (go->parse_length & 1) { in go7007_parse_video_stream()
668 go->modet_word |= buf[i]; in go7007_parse_video_stream()
669 write_bitmap_word(go); in go7007_parse_video_stream()
671 go->modet_word = buf[i] << 8; in go7007_parse_video_stream()
672 } else if (go->parse_length == 207 && vb) { in go7007_parse_video_stream()
675 if (++go->parse_length == 208) in go7007_parse_video_stream()
676 go->state = STATE_DATA; in go7007_parse_video_stream()
679 if (--go->parse_length == 0) in go7007_parse_video_stream()
680 go->state = STATE_DATA; in go7007_parse_video_stream()
693 struct go7007 *go; in go7007_alloc() local
696 go = kzalloc(sizeof(struct go7007), GFP_KERNEL); in go7007_alloc()
697 if (go == NULL) in go7007_alloc()
699 go->dev = dev; in go7007_alloc()
700 go->board_info = board; in go7007_alloc()
701 go->board_id = 0; in go7007_alloc()
702 go->tuner_type = -1; in go7007_alloc()
703 go->channel_number = 0; in go7007_alloc()
704 go->name[0] = 0; in go7007_alloc()
705 mutex_init(&go->hw_lock); in go7007_alloc()
706 init_waitqueue_head(&go->frame_waitq); in go7007_alloc()
707 spin_lock_init(&go->spinlock); in go7007_alloc()
708 go->status = STATUS_INIT; in go7007_alloc()
709 memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter)); in go7007_alloc()
710 go->i2c_adapter_online = 0; in go7007_alloc()
711 go->interrupt_available = 0; in go7007_alloc()
712 init_waitqueue_head(&go->interrupt_waitq); in go7007_alloc()
713 go->input = 0; in go7007_alloc()
714 go7007_update_board(go); in go7007_alloc()
715 go->encoder_h_halve = 0; in go7007_alloc()
716 go->encoder_v_halve = 0; in go7007_alloc()
717 go->encoder_subsample = 0; in go7007_alloc()
718 go->format = V4L2_PIX_FMT_MJPEG; in go7007_alloc()
719 go->bitrate = 1500000; in go7007_alloc()
720 go->fps_scale = 1; in go7007_alloc()
721 go->pali = 0; in go7007_alloc()
722 go->aspect_ratio = GO7007_RATIO_1_1; in go7007_alloc()
723 go->gop_size = 0; in go7007_alloc()
724 go->ipb = 0; in go7007_alloc()
725 go->closed_gop = 0; in go7007_alloc()
726 go->repeat_seqhead = 0; in go7007_alloc()
727 go->seq_header_enable = 0; in go7007_alloc()
728 go->gop_header_enable = 0; in go7007_alloc()
729 go->dvd_mode = 0; in go7007_alloc()
730 go->interlace_coding = 0; in go7007_alloc()
732 go->modet[i].enable = 0; in go7007_alloc()
734 go->modet_map[i] = 0; in go7007_alloc()
735 go->audio_deliver = NULL; in go7007_alloc()
736 go->audio_enabled = 0; in go7007_alloc()
738 return go; in go7007_alloc()
742 void go7007_update_board(struct go7007 *go) in go7007_update_board() argument
744 const struct go7007_board_info *board = go->board_info; in go7007_update_board()
747 go->standard = GO7007_STD_NTSC; in go7007_update_board()
748 go->std = V4L2_STD_NTSC_M; in go7007_update_board()
749 go->width = 720; in go7007_update_board()
750 go->height = 480; in go7007_update_board()
751 go->sensor_framerate = 30000; in go7007_update_board()
753 go->standard = GO7007_STD_OTHER; in go7007_update_board()
754 go->width = board->sensor_width; in go7007_update_board()
755 go->height = board->sensor_height; in go7007_update_board()
756 go->sensor_framerate = board->sensor_framerate; in go7007_update_board()
758 go->encoder_v_offset = board->sensor_v_offset; in go7007_update_board()
759 go->encoder_h_offset = board->sensor_h_offset; in go7007_update_board()