From 446d4199a156728c0a046418719b2f3a0645ad84 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 10 Mar 2009 19:28:16 -0700 Subject: zoran: Unify buffer descriptors From: Trent Piepho The zoran driver had two kinds of buffer descriptors, one for jpg buffers and one for raw buffers. They were mostly the same with only a couple different fields. A file handle had two sets of descriptors even though only one could be in use at once. I've combined the two kinds into a single buffer descriptor that has the different parts in a union. Each file handle (struct zoran_fh) now only has one set of buffers. The device itself (struct zoran) still has two since it can have both raw and jpg buffers in use at the same time. Along the way, I re-wrapped many lines that were ugly. Some code which was duplicated for both raw and jpg buffers is now merged. The code to setup buffers in zoran_open_init_session() can be merged, as can the code to delete the buffers in zoran_close_end_session(). Lots of code in zoran_vm_close() and zoran_mmap() is merged as well. Since there is now only one set of buffer size & count fields, it's important they get set correctly when changing modes. So I created helper functions to change fh->map_mode which also set the buffer size & count to the proper values. jpg_sync() should only be called in jpg mode, it used to be able to tell the difference between jpg mode active and raw mode, but now there is only one active field. In zoran_streamoff() the spin lock is held for the entire sequence of operations to disable streaming. Priority: normal Signed-off-by: Trent Piepho --- linux/drivers/media/video/zoran/zoran_device.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'linux/drivers/media/video/zoran/zoran_device.c') diff --git a/linux/drivers/media/video/zoran/zoran_device.c b/linux/drivers/media/video/zoran/zoran_device.c index c2dfd4b67..06f2c9a34 100644 --- a/linux/drivers/media/video/zoran/zoran_device.c +++ b/linux/drivers/media/video/zoran/zoran_device.c @@ -1126,7 +1126,7 @@ zoran_feed_stat_com (struct zoran *zr) if (!(zr->stat_com[i] & cpu_to_le32(1))) break; zr->stat_com[i] = - cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); + cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus); } else { /* fill 2 stat_com entries */ i = ((zr->jpg_dma_head - @@ -1134,9 +1134,9 @@ zoran_feed_stat_com (struct zoran *zr) if (!(zr->stat_com[i] & cpu_to_le32(1))) break; zr->stat_com[i] = - cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); + cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus); zr->stat_com[i + 1] = - cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); + cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus); } zr->jpg_buffers.buffer[frame].state = BUZ_STATE_DMA; zr->jpg_dma_head++; @@ -1156,7 +1156,7 @@ zoran_reap_stat_com (struct zoran *zr) u32 stat_com; unsigned int seq; unsigned int dif; - struct zoran_jpg_buffer *buffer; + struct zoran_buffer *buffer; int frame; /* In motion decompress we don't have a hardware frame counter, @@ -1299,7 +1299,7 @@ error_handler (struct zoran *zr, printk(KERN_INFO "stat_com frames:"); for (j = 0; j < BUZ_NUM_STAT_COM; j++) { for (i = 0; i < zr->jpg_buffers.num_buffers; i++) { - if (le32_to_cpu(zr->stat_com[j]) == zr->jpg_buffers.buffer[i].frag_tab_bus) + if (le32_to_cpu(zr->stat_com[j]) == zr->jpg_buffers.buffer[i].jpg.frag_tab_bus) printk(KERN_CONT "% d->%d", j, i); } } @@ -1443,7 +1443,7 @@ zoran_irq (int irq, /* Buffer address */ - reg = zr->v4l_buffers.buffer[frame].fbuffer_bus; + reg = zr->v4l_buffers.buffer[frame].v4l.fbuffer_bus; btwrite(reg, ZR36057_VDTR); if (zr->v4l_settings.height > BUZ_MAX_HEIGHT / 2) reg += zr->v4l_settings.bytesperline; -- cgit v1.2.3 From f542aede4d7c37a87c603e57f282b647c9550861 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 10 Mar 2009 19:28:31 -0700 Subject: zoran: Pass zoran_fh pointers instead of file pointers From: Trent Piepho Many functions had a struct file pointer argument, but all they wants is the struct zoran_fh pointer from the file's private data. Since every caller of those functions already has the zoran_fh, just pass the that instead. This saves a dereference in each function change. While I'm at it, change the code formatting of affected functions to be kernel standard style. Priority: normal Signed-off-by: Trent Piepho --- linux/drivers/media/video/zoran/zoran_device.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'linux/drivers/media/video/zoran/zoran_device.c') diff --git a/linux/drivers/media/video/zoran/zoran_device.c b/linux/drivers/media/video/zoran/zoran_device.c index 06f2c9a34..9d93dd8c0 100644 --- a/linux/drivers/media/video/zoran/zoran_device.c +++ b/linux/drivers/media/video/zoran/zoran_device.c @@ -536,12 +536,8 @@ zr36057_overlay (struct zoran *zr, * and the maximum window size is BUZ_MAX_WIDTH * BUZ_MAX_HEIGHT pixels. */ -void -write_overlay_mask (struct file *file, - struct v4l2_clip *vp, - int count) +void write_overlay_mask(struct zoran_fh *fh, struct v4l2_clip *vp, int count) { - struct zoran_fh *fh = file->private_data; struct zoran *zr = fh->zr; unsigned mask_line_size = (BUZ_MAX_WIDTH + 31) / 32; u32 *mask; -- cgit v1.2.3 From 70e434a0770289c85c4cf61a2956160e24d76bcf Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 8 Mar 2009 21:04:38 +0100 Subject: zoran/bt819: use new notify functionality. From: Hans Verkuil Bt819 needs the parent driver to drive a GPIO pin low and high in order to reset its fifo. Use the new notify callback for this. Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/zoran/zoran_device.c | 36 ++------------------------ 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'linux/drivers/media/video/zoran/zoran_device.c') diff --git a/linux/drivers/media/video/zoran/zoran_device.c b/linux/drivers/media/video/zoran/zoran_device.c index c2dfd4b67..409e0d5e1 100644 --- a/linux/drivers/media/video/zoran/zoran_device.c +++ b/linux/drivers/media/video/zoran/zoran_device.c @@ -1594,8 +1594,8 @@ zoran_init_hardware (struct zoran *zr) route.input = zr->card.input[zr->input].muxsel; decoder_call(zr, core, init, 0); - decoder_s_std(zr, zr->norm); - decoder_s_routing(zr, &route); + decoder_call(zr, tuner, s_std, zr->norm); + decoder_call(zr, video, s_routing, &route); encoder_call(zr, core, init, 0); encoder_call(zr, video, s_std_output, zr->norm); @@ -1660,35 +1660,3 @@ zr36057_init_vfe (struct zoran *zr) reg |= ZR36057_VDCR_Triton; btwrite(reg, ZR36057_VDCR); } - -/* - * Interface to decoder and encoder chips using i2c bus - */ - -int decoder_s_std(struct zoran *zr, v4l2_std_id std) -{ - int res; - - /* Bt819 needs to reset its FIFO buffer using #FRST pin and - LML33 card uses GPIO(7) for that. */ - if (zr->card.type == LML33) - GPIO(zr, 7, 0); - res = decoder_call(zr, tuner, s_std, std); - if (zr->card.type == LML33) - GPIO(zr, 7, 1); /* Pull #FRST high. */ - return res; -} - -int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route) -{ - int res; - - /* Bt819 needs to reset its FIFO buffer using #FRST pin and - LML33 card uses GPIO(7) for that. */ - if (zr->card.type == LML33) - GPIO(zr, 7, 0); - res = decoder_call(zr, video, s_routing, route); - if (zr->card.type == LML33) - GPIO(zr, 7, 1); /* Pull #FRST high. */ - return res; -} -- cgit v1.2.3 From 0811e7462ce5c70637faa77e010016680c1e971a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 1 Apr 2009 08:52:39 +0200 Subject: v4l2-subdev: move s_std from tuner to core. From: Hans Verkuil s_std didn't belong in the tuner ops. Stricly speaking it should be part of the video ops, but it is used by audio and tuner devices as well, so it is more efficient to make it part of the core ops. Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/zoran/zoran_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/drivers/media/video/zoran/zoran_device.c') diff --git a/linux/drivers/media/video/zoran/zoran_device.c b/linux/drivers/media/video/zoran/zoran_device.c index 54a04ea5c..b2880095c 100644 --- a/linux/drivers/media/video/zoran/zoran_device.c +++ b/linux/drivers/media/video/zoran/zoran_device.c @@ -1590,7 +1590,7 @@ zoran_init_hardware (struct zoran *zr) route.input = zr->card.input[zr->input].muxsel; decoder_call(zr, core, init, 0); - decoder_call(zr, tuner, s_std, zr->norm); + decoder_call(zr, core, s_std, zr->norm); decoder_call(zr, video, s_routing, &route); encoder_call(zr, core, init, 0); -- cgit v1.2.3 From b4d23428b3c4456414ad8bf5e974757fd354a66f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 2 Apr 2009 16:26:22 +0200 Subject: v4l2-subdev: change s_routing prototype From: Hans Verkuil It is no longer needed to use a struct pointer as argument, since v4l2_subdev doesn't require that ioctl-like approach anymore. Instead just pass the input, output and config (new!) arguments directly. Priority: normal Signed-off-by: Hans Verkuil --- linux/drivers/media/video/zoran/zoran_device.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'linux/drivers/media/video/zoran/zoran_device.c') diff --git a/linux/drivers/media/video/zoran/zoran_device.c b/linux/drivers/media/video/zoran/zoran_device.c index b2880095c..4f656f682 100644 --- a/linux/drivers/media/video/zoran/zoran_device.c +++ b/linux/drivers/media/video/zoran/zoran_device.c @@ -972,7 +972,6 @@ zr36057_enable_jpg (struct zoran *zr, struct vfe_settings cap; int field_size = zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; - struct v4l2_routing route = { 0, 0 }; zr->codec_mode = mode; @@ -995,8 +994,7 @@ zr36057_enable_jpg (struct zoran *zr, */ set_videobus_dir(zr, 0); decoder_call(zr, video, s_stream, 1); - route.input = 0; - encoder_call(zr, video, s_routing, &route); + encoder_call(zr, video, s_routing, 0, 0, 0); /* Take the JPEG codec and the VFE out of sleep */ jpeg_codec_sleep(zr, 0); @@ -1044,8 +1042,7 @@ zr36057_enable_jpg (struct zoran *zr, */ decoder_call(zr, video, s_stream, 0); set_videobus_dir(zr, 1); - route.input = 1; - encoder_call(zr, video, s_routing, &route); + encoder_call(zr, video, s_routing, 1, 0, 0); /* Take the JPEG codec and the VFE out of sleep */ jpeg_codec_sleep(zr, 0); @@ -1090,8 +1087,7 @@ zr36057_enable_jpg (struct zoran *zr, zr36057_adjust_vfe(zr, mode); decoder_call(zr, video, s_stream, 1); - route.input = 0; - encoder_call(zr, video, s_routing, &route); + encoder_call(zr, video, s_routing, 0, 0, 0); dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); break; @@ -1577,8 +1573,6 @@ zoran_set_pci_master (struct zoran *zr, void zoran_init_hardware (struct zoran *zr) { - struct v4l2_routing route = { 0, 0 }; - /* Enable bus-mastering */ zoran_set_pci_master(zr, 1); @@ -1587,16 +1581,14 @@ zoran_init_hardware (struct zoran *zr) zr->card.init(zr); } - route.input = zr->card.input[zr->input].muxsel; - decoder_call(zr, core, init, 0); decoder_call(zr, core, s_std, zr->norm); - decoder_call(zr, video, s_routing, &route); + decoder_call(zr, video, s_routing, + zr->card.input[zr->input].muxsel, 0, 0); encoder_call(zr, core, init, 0); encoder_call(zr, video, s_std_output, zr->norm); - route.input = 0; - encoder_call(zr, video, s_routing, &route); + encoder_call(zr, video, s_routing, 0, 0, 0); /* toggle JPEG codec sleep to sync PLL */ jpeg_codec_sleep(zr, 1); -- cgit v1.2.3