[PATCH 0/2] radio-timb: Simplified platform data and open function added
To follow are two patches for the timberdale radio driver. The first just simplifies the platform data. The second uses the platform data to find a tuner and DSP on a provided I2C bus. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] radio-timb: Add open function which finds tuner and DSP via I2C
This patch uses the platform data and finds a tuner and DSP. This is done when the user calls open. Not during probe, to allow shorter bootup time of the system. This piece of code was actually missing earlier, many of the functions were not useful without DSP and tuner. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index a185610..64a5e19 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -141,9 +141,42 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_s_ctrl = timbradio_vidioc_s_ctrl }; +static int timbradio_fops_open(struct file *file) +{ + struct timbradio *tr = video_drvdata(file); + struct i2c_adapter *adapt; + + /* find the I2C bus */ + adapt = i2c_get_adapter(tr-pdata.i2c_adapter); + if (!adapt) { + printk(KERN_ERR DRIVER_NAME: No I2C bus\n); + return -ENODEV; + } + + /* now find the tuner and dsp */ + if (!tr-sd_dsp) + tr-sd_dsp = v4l2_i2c_new_subdev_board(tr-v4l2_dev, adapt, + tr-pdata.dsp, NULL); + + if (!tr-sd_tuner) + tr-sd_tuner = v4l2_i2c_new_subdev_board(tr-v4l2_dev, adapt, + tr-pdata.tuner, NULL); + + i2c_put_adapter(adapt); + + if (!tr-sd_tuner || !tr-sd_dsp) { + printk(KERN_ERR DRIVER_NAME + : Failed to get tuner or DSP\n); + return -ENODEV; + } + + return 0; +} + static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, + .open = timbradio_fops_open, }; static int __devinit timbradio_probe(struct platform_device *pdev) -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] radio-timb: Simplified platform data
This patch simplifies the platform data slightly, by removing unused elements. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 69272e4..696879e 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -287,12 +287,8 @@ static __devinitdata struct i2c_board_info timberdale_saa7706_i2c_board_info = { static __devinitdata struct timb_radio_platform_data timberdale_radio_platform_data = { .i2c_adapter = 0, - .tuner = { - .info = timberdale_tef6868_i2c_board_info - }, - .dsp = { - .info = timberdale_saa7706_i2c_board_info - } + .tuner = timberdale_tef6868_i2c_board_info, + .dsp = timberdale_saa7706_i2c_board_info }; static const __devinitconst struct resource timberdale_video_resources[] = { diff --git a/include/media/timb_radio.h b/include/media/timb_radio.h index a59a848..a40a6a3 100644 --- a/include/media/timb_radio.h +++ b/include/media/timb_radio.h @@ -23,13 +23,8 @@ struct timb_radio_platform_data { int i2c_adapter; /* I2C adapter where the tuner and dsp are attached */ - struct { - struct i2c_board_info *info; - } tuner; - struct { - const char *module_name; - struct i2c_board_info *info; - } dsp; + struct i2c_board_info *tuner; + struct i2c_board_info *dsp; }; #endif -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/1] radio-timb: Add tuner and DSP to the I2C bus
On 11/26/2010 11:03 AM, Hans Verkuil wrote: On Friday, November 26, 2010 10:51:10 Richard Röjfors wrote: To follow is a patch to add the tuner and DSP passed in the platform data to the I2C bus. This patch is to be applied after Hans' patch to remove usage of the blocking ioctl. Is this something you need to have fixed for 2.6.37, or is 2.6.38 good enough? It seems like this didn't make it to 2.6.38-rc1, is it possible to get it in before the final 2.6.38? This is a bug fix... --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: radio-timb: proposed patch to convert to unlocked_ioctl
Hi Hans, On 11/14/2010 02:56 PM, Hans Verkuil wrote: Hi Richard, Can you check if this patch is OK? It's against the v2.6.38 media_tree branch. This patch is OK. I uncovered that the dsp and tuner are never added to the I2C bus, I'll provide a patch for it shortly which I would like you to apply after this patch. It converts .ioctl to unlocked_ioctl by using the new v4l2 core locking. Before it relied on the BKL to do the locking, but that is being phased out. Regards, Hans Acked-by: Richard Röjfors richard.rojf...@pelagicore.com diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index b8bb3ef..a185610 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -34,6 +34,7 @@ struct timbradio { struct v4l2_subdev *sd_dsp; struct video_device video_dev; struct v4l2_device v4l2_dev; + struct mutexlock; }; @@ -142,7 +143,7 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, - .ioctl = video_ioctl2, + .unlocked_ioctl = video_ioctl2, }; static int __devinit timbradio_probe(struct platform_device *pdev) @@ -164,6 +165,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev) } tr-pdata = *pdata; + mutex_init(tr-lock); strlcpy(tr-video_dev.name, Timberdale Radio, sizeof(tr-video_dev.name)); @@ -171,6 +173,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev) tr-video_dev.ioctl_ops = timbradio_ioctl_ops; tr-video_dev.release = video_device_release_empty; tr-video_dev.minor = -1; + tr-video_dev.lock = tr-lock; strlcpy(tr-v4l2_dev.name, DRIVER_NAME, sizeof(tr-v4l2_dev.name)); err = v4l2_device_register(NULL, tr-v4l2_dev); -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/1] radio-timb: Add tuner and DSP to the I2C bus
To follow is a patch to add the tuner and DSP passed in the platform data to the I2C bus. This patch is to be applied after Hans' patch to remove usage of the blocking ioctl. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] radio-timb: Add tuner and DSP to the I2C bus
This patch adds an open function to the radio-timb, which adds the DSP an tuner to the I2C bus. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index a185610..2b7abe2 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -141,9 +141,50 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_s_ctrl = timbradio_vidioc_s_ctrl }; +static int timbradio_fops_open(struct file *file) +{ + struct timbradio *tr = video_drvdata(file); + struct i2c_adapter *adapt; + int err = 0; + + mutex_lock(tr-lock); + + /* find the I2C bus */ + adapt = i2c_get_adapter(tr-pdata.i2c_adapter); + if (!adapt) { + printk(KERN_ERR DRIVER_NAME: No I2C bus\n); + err = -ENODEV; + goto out; + } + + /* now find the tuner and dsp */ + if (!tr-sd_dsp) + tr-sd_dsp = v4l2_i2c_new_subdev_board(tr-v4l2_dev, adapt, + tr-pdata.dsp.module_name, tr-pdata.dsp.info, NULL); + + if (!tr-sd_tuner) + tr-sd_tuner = v4l2_i2c_new_subdev_board(tr-v4l2_dev, adapt, + tr-pdata.tuner.module_name, tr-pdata.tuner.info, + NULL); + + i2c_put_adapter(adapt); + + if (!tr-sd_tuner || !tr-sd_dsp) { + printk(KERN_ERR DRIVER_NAME + : Failed to get tuner or DSP\n); + err = -ENODEV; + goto out; + } + +out: + mutex_unlock(tr-lock); + return err; +} + static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, + .open = timbradio_fops_open, }; static int __devinit timbradio_probe(struct platform_device *pdev) -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/1] radio-timb: Add tuner and DSP to the I2C bus
On 11/26/2010 11:03 AM, Hans Verkuil wrote: On Friday, November 26, 2010 10:51:10 Richard Röjfors wrote: To follow is a patch to add the tuner and DSP passed in the platform data to the I2C bus. This patch is to be applied after Hans' patch to remove usage of the blocking ioctl. Is this something you need to have fixed for 2.6.37, or is 2.6.38 good enough? 2.6.38 is good enough. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] media: fix casting issues in timberdale logiwin
On 11/24/2010 10:41 AM, Richard Röjfors wrote: On 11/23/2010 09:39 PM, Jarod Wilson wrote: I get warnings about casting to and from pointers and integers of different sizes w/current code, this silences them. Signed-off-by: Jarod Wilson ja...@redhat.com Looks good, and works. I did a mistake and tested the wrong binary, this patch is NOT ok. Mauro please to do apply this patch. Acked-by: Richard Röjfors richard.rojf...@pelagicore.com --- drivers/media/video/timblogiw.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c index 48989e5..4da3625 100644 --- a/drivers/media/video/timblogiw.c +++ b/drivers/media/video/timblogiw.c @@ -148,7 +148,9 @@ static void timblogiw_dma_cb(void *data) static bool timblogiw_dma_filter_fn(struct dma_chan *chan, void *filter_param) { -return chan-chan_id == (int)filter_param; +int chan_id = *(int *)filter_param; + +return chan-chan_id == chan_id; } This part dereferences the pointer, which actually is a type casted int! /* IOCTL functions */ @@ -670,7 +672,7 @@ static int timblogiw_open(struct file *file) /* find the DMA channel */ fh-chan = dma_request_channel(mask, timblogiw_dma_filter_fn, -(void *)lw-pdata.dma_channel); +(void *)(unsigned long)lw-pdata.dma_channel); You see here, the channel is type casted to a pointer, not something we want to dereference as above. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] media: fix casting issues in timberdale logiwin
On 11/23/2010 09:39 PM, Jarod Wilson wrote: I get warnings about casting to and from pointers and integers of different sizes w/current code, this silences them. Signed-off-by: Jarod Wilson ja...@redhat.com Looks good, and works. Acked-by: Richard Röjfors richard.rojf...@pelagicore.com --- drivers/media/video/timblogiw.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c index 48989e5..4da3625 100644 --- a/drivers/media/video/timblogiw.c +++ b/drivers/media/video/timblogiw.c @@ -148,7 +148,9 @@ static void timblogiw_dma_cb(void *data) static bool timblogiw_dma_filter_fn(struct dma_chan *chan, void *filter_param) { - return chan-chan_id == (int)filter_param; + int chan_id = *(int *)filter_param; + + return chan-chan_id == chan_id; } /* IOCTL functions */ @@ -670,7 +672,7 @@ static int timblogiw_open(struct file *file) /* find the DMA channel */ fh-chan = dma_request_channel(mask, timblogiw_dma_filter_fn, - (void *)lw-pdata.dma_channel); + (void *)(unsigned long)lw-pdata.dma_channel); if (!fh-chan) { dev_err(vdev-dev, Failed to get DMA channel\n); kfree(fh); -- = Richard Röjfors Software Architect Pelagicore AB Ekelundsgatan 4, 6tr, SE-411 18 Gothenburg, Sweden Mobile: +46 (0)708 88 97 91 E-Mail: richard.rojf...@pelagicore.com = === NOTE === The information contained in this E-mail message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. = -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: radio-timb: proposed patch to convert to unlocked_ioctl
Hi Hans, On 11/14/2010 02:56 PM, Hans Verkuil wrote: Hi Richard, Can you check if this patch is OK? It's against the v2.6.38 media_tree branch. Sorry for a late response, I will look at this now. Thanks for the patch work! --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2 v4] media, mfd: Add timberdale video-in driver
To follow are two patches. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. Changes since last version: * Updated according the API changed in 2.6.37. As Samuel pointed out earlier the patch to timberdale should be trivial so I hope Mauro can take the patches via his tree. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2 v4] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index ac16e81..647cf9a 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -666,6 +666,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index af79d47..482f14b 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -106,6 +106,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..48989e5 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,895 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 30 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm
[PATCH 2/2 v4] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com Acked-by: Samuel Ortiz sa...@linux.intel.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 727f62c..6e53a16 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -246,7 +247,24 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; -static const __devinitconst struct resource timberdale_radio_resources[] = { +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + +static const __devinitconst struct resource +timberdale_radio_resources[] = { { .start = RDSOFFSET, .end= RDSEND, @@ -280,6 +298,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -380,6 +410,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -440,6 +477,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -490,6 +534,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -533,6 +584,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3
[PATCH 1/2 v3] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f6e4d04..1afbe26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -734,6 +734,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 40f98fb..c93af35 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -109,6 +109,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..a3a330f --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,894 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 30 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm
[PATCH 0/2 v3] media, mfd: Add timberdale video-in driver
To follow are two patches. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. Changes since last version: * Using the unlocked_ioctl to avoid BKL, instead using a mutex in the ioctl callbacks where needed. * The try_fmt function does _not_ set the format anymore. As Samuel pointed out earlier the patch to timberdale should be trivial so I hope Mauro can take the patches via his tree. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2 v3] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com Acked-by: Samuel Ortiz sa...@linux.intel.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..52a651b 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,7 +239,24 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; -static const __devinitconst struct resource timberdale_radio_resources[] = { +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + +static const __devinitconst struct resource +timberdale_radio_resources[] = { { .start = RDSOFFSET, .end= RDSEND, @@ -272,6 +290,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +402,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +467,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +522,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +572,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3
[RESEND][PATCH 2/2 v2] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..52a651b 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,7 +239,24 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; -static const __devinitconst struct resource timberdale_radio_resources[] = { +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + +static const __devinitconst struct resource +timberdale_radio_resources[] = { { .start = RDSOFFSET, .end= RDSEND, @@ -272,6 +290,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +402,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +467,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +522,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +572,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3 -- To unsubscribe from this list: send the line
[RESEND][PATCH 0/2 v2] media, mfd: Add timberdale video-in driver
To follow are two patches. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. I hope Mauro can take the patches via his tree. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND][PATCH 1/2 v2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f6e4d04..1afbe26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -734,6 +734,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 40f98fb..c93af35 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -109,6 +109,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..549c0be --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,881 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 30 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm
Re: [RESEND][PATCH 1/2] media: Add timberdale video-in driver
Thanks for the feedback, I will post an updated patch. Comments below. On 09/08/2010 09:35 PM, Mauro Carvalho Chehab wrote: Em 02-09-2010 08:56, Richard Röjfors escreveu: This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjforsrichard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f6e4d04..1afbe26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -734,6 +734,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 40f98fb..c93af35 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -109,6 +109,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..1ccc620 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,877 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#includelinux/version.h +#includelinux/platform_device.h +#includelinux/slab.h +#includelinux/dmaengine.h +#includelinux/scatterlist.h +#includelinux/interrupt.h +#includelinux/list.h +#includelinux/i2c.h +#includemedia/v4l2-ioctl.h +#includemedia/v4l2-device.h +#includemedia/videobuf-dma-contig.h +#includemedia/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY Hmm... why are you using a constant here? Does this device provide the standard UYVY fourcc format, or does it have a different (proprietary) format? I will change to use the V4L2 define in the code instead of an own. The framegrabber follows the standard. If it uses the standard format, just use the standard definition. Otherwise, we need to add a new format to the V4L2 API, to make sure that userspace applications and libv4l will properly handle it. + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb
[PATCH 0/2 v2] media, mfd: Add timberdale video-in driver
To follow are two patches. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. As Mauro pointed out earlier the patch to timberdale should be trivial so I hope Mauro can take the patches via his tree. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2 v2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f6e4d04..1afbe26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -734,6 +734,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 40f98fb..c93af35 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -109,6 +109,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..549c0be --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,881 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 30 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm
[PATCH 2/2 v2] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..52a651b 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,7 +239,24 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; -static const __devinitconst struct resource timberdale_radio_resources[] = { +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + +static const __devinitconst struct resource +timberdale_radio_resources[] = { { .start = RDSOFFSET, .end= RDSEND, @@ -272,6 +290,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +402,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +467,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +522,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +572,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3 -- To unsubscribe from this list: send the line
[RESEND][PATCH 0/2] media, mfd: Add timberdale video-in driver
To follow are two patches. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. Samuel and Mauro hope you can support and solve the potential merge issue between your two trees. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND][PATCH 1/2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f6e4d04..1afbe26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -734,6 +734,15 @@ config VIDEO_HEXIUM_GEMINI To compile this driver as a module, choose M here: the module will be called hexium_gemini. +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + source drivers/media/video/cx88/Kconfig source drivers/media/video/cx23885/Kconfig diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 40f98fb..c93af35 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -109,6 +109,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..1ccc620 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,877 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 26 + } +}; + +static int
[RESEND][PATCH 2/2] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..52a651b 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,7 +239,24 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; -static const __devinitconst struct resource timberdale_radio_resources[] = { +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + +static const __devinitconst struct resource +timberdale_radio_resources[] = { { .start = RDSOFFSET, .end= RDSEND, @@ -272,6 +290,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +402,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +467,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +522,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +572,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3 -- To unsubscribe from this list: send the line
[PATCH 0/2 v3] media, mfd: Add timberdale video-in driver
To follow are three patches. Since last patch I removed the uncached buffers patch, it needs to be investigated further. The first adds the timberdale video-in driver to the media tree. The second adds it to the timberdale MFD driver. Samuel and Mauro hope you can support and solve the potential merge issue between your two trees. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2 v3] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index bdbc9d3..43c3277 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -969,6 +969,15 @@ config VIDEO_OMAP2 ---help--- This is a v4l2 driver for the TI OMAP2 camera capture interface +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + # # USB Multimedia device configuration # diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index cc93859..39750e0 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -110,6 +110,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..1ccc620 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,877 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 26 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm) +{ + return
[PATCH 2/2 v3] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..d4a95bd 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,6 +239,22 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + static const __devinitconst struct resource timberdale_radio_resources[] = { { .start = RDSOFFSET, @@ -272,6 +289,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +401,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +466,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +521,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +571,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http
Re: [PATCH 1/3 v2] media: Add a cached version of the contiguous video buffers
On 08/04/2010 12:34 PM, Pawel Osciak wrote: Richard Röjforsrichard.rojf...@pelagicore.com wrote: On 08/04/2010 11:50 AM, Pawel Osciak wrote: How do you propose to allocate the buffers? They need to be contiguous and using uncached memory gave really bad performance. 829440 bytes is a quite a lot and one can't reliably depend on kmalloc to be able to allocate such big chunks of contiguous memory. Were you testing this on a freshly rebooted system? The systems have been running for a while, but not days. I don't see why would dma_alloc_coherent work better than kmalloc? In principle it wouldn't. It's just it's much less intensively used and allocates from a special area. Not really a bullet-proof solution either though, I agree. So how do we move forward? I would like to see this kind of patch go in, it obviously makes our video driver useful. I could change and verify the patch using dma_alloc_noncoherent instead of kmalloc. It would have the same limitations as todays' uncached buffers. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3 v2] media: Add a cached version of the contiguous video buffers
On 08/04/2010 09:55 AM, Pawel Osciak wrote: Hi Richard, Richard Röjfors wrote: This patch adds another init functions in the videobuf-dma-contig which is named _cached in the end. It creates a buffer factory which allocates buffers using kmalloc and the buffers are cached. Before I review this in more detail, could you elaborate more on this? How large are your buffers, can kmalloc really allocate them for you? I am not convinced how this is supposed to work reliably, especially in a long-running systems. The buffers are normally 829440 bytes and yes kmalloc can allocate them. Normally userspace apps seem to request two buffers of this size. How do you propose to allocate the buffers? They need to be contiguous and using uncached memory gave really bad performance. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3 v2] media: Add a cached version of the contiguous video buffers
This patch adds another init functions in the videobuf-dma-contig which is named _cached in the end. It creates a buffer factory which allocates buffers using kmalloc and the buffers are cached. A sync callback is added to sync the buffers. Most of the code is reused from the uncached version a bool is added to the memory struct to flag if the buffers are to be cached or not. The reason is that I found the performance of the uncached buffers was too poor on an atom-based X86, so I added this cached version. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index 74730c6..a35f65a 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c @@ -27,6 +27,7 @@ struct videobuf_dma_contig_memory { u32 magic; void *vaddr; dma_addr_t dma_handle; + bool cached; unsigned long size; int is_userptr; }; @@ -38,6 +39,54 @@ struct videobuf_dma_contig_memory { BUG(); \ } +static int __videobuf_dc_alloc(struct device *dev, + struct videobuf_dma_contig_memory *mem, unsigned long size) +{ + mem-size = size; + if (mem-cached) { + mem-vaddr = kmalloc(mem-size, GFP_KERNEL); + if (mem-vaddr) { + int err; + + mem-dma_handle = dma_map_single(dev, mem-vaddr, + mem-size, DMA_FROM_DEVICE); + err = dma_mapping_error(dev, mem-dma_handle); + if (err) { + dev_err(dev, dma_map_single failed\n); + + kfree(mem-vaddr); + mem-vaddr = 0; + return err; + } + } + } else + mem-vaddr = dma_alloc_coherent(dev, mem-size, + mem-dma_handle, GFP_KERNEL); + + if (!mem-vaddr) { + dev_err(dev, memory alloc size %ld failed\n, + mem-size); + return -ENOMEM; + } + + dev_dbg(dev, dma mapped data is at %p (%ld)\n, mem-vaddr, mem-size); + + return 0; +} + +static void __videobuf_dc_free(struct device *dev, + struct videobuf_dma_contig_memory *mem) +{ + if (mem-cached) { + dma_unmap_single(dev, mem-dma_handle, mem-size, + DMA_FROM_DEVICE); + kfree(mem-vaddr); + } else + dma_free_coherent(dev, mem-size, mem-vaddr, mem-dma_handle); + + mem-vaddr = NULL; +} + static void videobuf_vm_open(struct vm_area_struct *vma) { @@ -92,9 +141,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dev_dbg(q-dev, buf[%d] freeing %p\n, i, mem-vaddr); - dma_free_coherent(q-dev, mem-size, - mem-vaddr, mem-dma_handle); - mem-vaddr = NULL; + __videobuf_dc_free(q-dev, mem); } q-bufs[i]-map = NULL; @@ -190,7 +237,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, return ret; } -static struct videobuf_buffer *__videobuf_alloc(size_t size) +static struct videobuf_buffer *__videobuf_alloc(size_t size, bool cached) { struct videobuf_dma_contig_memory *mem; struct videobuf_buffer *vb; @@ -199,11 +246,22 @@ static struct videobuf_buffer *__videobuf_alloc(size_t size) if (vb) { mem = vb-priv = ((char *)vb) + size; mem-magic = MAGIC_DC_MEM; + mem-cached = cached; } return vb; } +static struct videobuf_buffer *__videobuf_alloc_uncached(size_t size) +{ + return __videobuf_alloc(size, false); +} + +static struct videobuf_buffer *__videobuf_alloc_cached(size_t size) +{ + return __videobuf_alloc(size, true); +} + static void *__videobuf_to_vaddr(struct videobuf_buffer *buf) { struct videobuf_dma_contig_memory *mem = buf-priv; @@ -241,17 +299,8 @@ static int __videobuf_iolock(struct videobuf_queue *q, return videobuf_dma_contig_user_get(mem, vb); /* allocate memory for the read() method */ - mem-size = PAGE_ALIGN(vb-size); - mem-vaddr = dma_alloc_coherent(q-dev, mem-size, - mem-dma_handle, GFP_KERNEL); - if (!mem-vaddr) { - dev_err(q-dev, dma_alloc_coherent %ld failed\n, -mem-size); + if (__videobuf_dc_alloc(q-dev, mem, PAGE_ALIGN(vb-size))) return
[PATCH 0/3 v2] media, mfd: Add timberdale video-in driver
To follow are three patches. The first adds in a cached version of the DMA contiguous video buffers. The second adds the timberdale video-in driver to the media tree. The third adds it to the timberdale MFD driver. Samuel and Mauro hope you can support and solve the potential merge issue between your two trees. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3 v2] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index ac59950..d4a95bd 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,6 +239,22 @@ static const __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + static const __devinitconst struct resource timberdale_radio_resources[] = { { .start = RDSOFFSET, @@ -272,6 +289,18 @@ static __devinitdata struct timb_radio_platform_data } }; +static const __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +401,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +466,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +521,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +571,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, diff --git a/drivers/mfd/timberdale.h b/drivers/mfd/timberdale.h index c11bf6e..4412acd 100644 --- a/drivers/mfd/timberdale.h +++ b/drivers/mfd/timberdale.h @@ -23,7 +23,7 @@ #ifndef MFD_TIMBERDALE_H #define MFD_TIMBERDALE_H -#define DRV_VERSION0.2 +#define DRV_VERSION0.3 /* This driver only support versions = 3.8 and 4.0 */ #define TIMB_SUPPORTED_MAJOR 3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http
[PATCH 2/3 v2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 video buffers to handle buffers against user space. Due to poor performance using uncached buffers, it uses cached buffers, added in the previous patch. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index bdbc9d3..43c3277 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -969,6 +969,15 @@ config VIDEO_OMAP2 ---help--- This is a v4l2 driver for the TI OMAP2 camera capture interface +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_DMA_CONTIG + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + # # USB Multimedia device configuration # diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index cc93859..39750e0 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -110,6 +110,7 @@ obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ obj-$(CONFIG_VIDEO_MXB) += mxb.o obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..2bef159 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,878 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-dma-contig.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + unsigned intframe_count; +}; + +struct timblogiw_buffer { + /* common v4l buffer stuff -- must be first */ + struct videobuf_buffer vb; + struct scatterlist sg[16]; + dma_cookie_tcookie; + struct timblogiw_fh *fh; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 26
Re: [PATCH 1/2] media: Add timberdale video-in driver
Hi, On 05/26/2010 04:19 PM, Richard Röjfors wrote: Hi Mauro, On Sun, 2010-04-25 at 13:13 -0300, Mauro Carvalho Chehab wrote: 2. I tried using videobuf-dma-contig, but got poor performance. I can not really explain why, I though it's due to the fact that the contiguous buffer is allocated coherent - no caching. I saw both gstreamer and mplayer perform very badly. The frame grabber requires the DMA transfer for a frame beeing started while the frame is decoded. When I tested using contigous buffers gstreamer sometimes was that slow that it sometimes missed to have a frame queued when a transfer was finished, so I got frame drops. Any other ideas of the poor performance? otherwise I would like to go for the double buffered solution. The better is to fix videobuf-dma_contig to better work on your hardware. It makes sense to add a flag to allow specifying if it should use coherent or non-coherent memory for the dma buffer alloc/free calls. I have verified the performance issue and it goes back to non cached coherent buffers. I did an update to the videobuf-dma-contig. I did it by adding another init function, which calls videobuf_queue_core_init with another set of qops. The other set uses the same functions as the uncached version, but a sync function is added, and the alloc_functions are different. What do you think? Any comments on this? I know it doesn't apply on 2.6.35. But the general idea of how to add in cache support in the contig buffer code. On our platform we get much better (useful) performance using cached buffers. //Richard Signed-off-by: Richard Röjforsrichard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index dce4f3a..2fc923c 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c @@ -27,6 +27,7 @@ struct videobuf_dma_contig_memory { u32 magic; void *vaddr; dma_addr_t dma_handle; + bool cached; unsigned long size; int is_userptr; }; @@ -38,6 +39,54 @@ struct videobuf_dma_contig_memory { BUG(); \ } +static int __videobuf_dc_alloc(struct device *dev, + struct videobuf_dma_contig_memory *mem, unsigned long size) +{ + mem-size = size; + if (mem-cached) { + mem-vaddr = kmalloc(mem-size, GFP_KERNEL); + if (mem-vaddr) { + int err; + + mem-dma_handle = dma_map_single(dev, mem-vaddr, + mem-size, DMA_FROM_DEVICE); + err = dma_mapping_error(dev, mem-dma_handle); + if (err) { + dev_err(dev, dma_map_single failed\n); + + kfree(mem-vaddr); + mem-vaddr = 0; + return err; + } + } + } else + mem-vaddr = dma_alloc_coherent(dev, mem-size, + mem-dma_handle, GFP_KERNEL); + + if (!mem-vaddr) { + dev_err(dev, memory alloc size %ld failed\n, + mem-size); + return -ENOMEM; + } + + dev_dbg(dev, dma mapped data is at %p (%ld)\n, mem-vaddr, mem-size); + + return 0; +} + +static void __videobuf_dc_free(struct device *dev, + struct videobuf_dma_contig_memory *mem) +{ + if (mem-cached) { + dma_unmap_single(dev, mem-dma_handle, mem-size, + DMA_FROM_DEVICE); + kfree(mem-vaddr); + } else + dma_free_coherent(dev, mem-size, mem-vaddr, mem-dma_handle); + + mem-vaddr = NULL; +} + static void videobuf_vm_open(struct vm_area_struct *vma) { @@ -92,9 +141,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dev_dbg(map-q-dev, buf[%d] freeing %p\n, i, mem-vaddr); - dma_free_coherent(q-dev, mem-size, - mem-vaddr, mem-dma_handle); - mem-vaddr = NULL; + __videobuf_dc_free(q-dev, mem); } q-bufs[i]-map = NULL; @@ -190,7 +237,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, return ret; } -static void *__videobuf_alloc(size_t size) +static void *__videobuf_alloc(size_t size, bool cached) { struct videobuf_dma_contig_memory *mem; struct videobuf_buffer *vb; @@ -199,11 +246,22 @@ static void *__videobuf_alloc(size_t size) if (vb) { mem = vb-priv = ((char *)vb) + size; mem-magic = MAGIC_DC_MEM; + mem-cached = cached; } return vb; } +static void
Re: [PATCH 1/2] media: Add timberdale video-in driver
Hi Mauro, On Sun, 2010-04-25 at 13:13 -0300, Mauro Carvalho Chehab wrote: 2. I tried using videobuf-dma-contig, but got poor performance. I can not really explain why, I though it's due to the fact that the contiguous buffer is allocated coherent - no caching. I saw both gstreamer and mplayer perform very badly. The frame grabber requires the DMA transfer for a frame beeing started while the frame is decoded. When I tested using contigous buffers gstreamer sometimes was that slow that it sometimes missed to have a frame queued when a transfer was finished, so I got frame drops. Any other ideas of the poor performance? otherwise I would like to go for the double buffered solution. The better is to fix videobuf-dma_contig to better work on your hardware. It makes sense to add a flag to allow specifying if it should use coherent or non-coherent memory for the dma buffer alloc/free calls. I have verified the performance issue and it goes back to non cached coherent buffers. I did an update to the videobuf-dma-contig. I did it by adding another init function, which calls videobuf_queue_core_init with another set of qops. The other set uses the same functions as the uncached version, but a sync function is added, and the alloc_functions are different. What do you think? Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index dce4f3a..2fc923c 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c @@ -27,6 +27,7 @@ struct videobuf_dma_contig_memory { u32 magic; void *vaddr; dma_addr_t dma_handle; + bool cached; unsigned long size; int is_userptr; }; @@ -38,6 +39,54 @@ struct videobuf_dma_contig_memory { BUG(); \ } +static int __videobuf_dc_alloc(struct device *dev, + struct videobuf_dma_contig_memory *mem, unsigned long size) +{ + mem-size = size; + if (mem-cached) { + mem-vaddr = kmalloc(mem-size, GFP_KERNEL); + if (mem-vaddr) { + int err; + + mem-dma_handle = dma_map_single(dev, mem-vaddr, + mem-size, DMA_FROM_DEVICE); + err = dma_mapping_error(dev, mem-dma_handle); + if (err) { + dev_err(dev, dma_map_single failed\n); + + kfree(mem-vaddr); + mem-vaddr = 0; + return err; + } + } + } else + mem-vaddr = dma_alloc_coherent(dev, mem-size, + mem-dma_handle, GFP_KERNEL); + + if (!mem-vaddr) { + dev_err(dev, memory alloc size %ld failed\n, + mem-size); + return -ENOMEM; + } + + dev_dbg(dev, dma mapped data is at %p (%ld)\n, mem-vaddr, mem-size); + + return 0; +} + +static void __videobuf_dc_free(struct device *dev, + struct videobuf_dma_contig_memory *mem) +{ + if (mem-cached) { + dma_unmap_single(dev, mem-dma_handle, mem-size, + DMA_FROM_DEVICE); + kfree(mem-vaddr); + } else + dma_free_coherent(dev, mem-size, mem-vaddr, mem-dma_handle); + + mem-vaddr = NULL; +} + static void videobuf_vm_open(struct vm_area_struct *vma) { @@ -92,9 +141,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dev_dbg(map-q-dev, buf[%d] freeing %p\n, i, mem-vaddr); - dma_free_coherent(q-dev, mem-size, - mem-vaddr, mem-dma_handle); - mem-vaddr = NULL; + __videobuf_dc_free(q-dev, mem); } q-bufs[i]-map = NULL; @@ -190,7 +237,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, return ret; } -static void *__videobuf_alloc(size_t size) +static void *__videobuf_alloc(size_t size, bool cached) { struct videobuf_dma_contig_memory *mem; struct videobuf_buffer *vb; @@ -199,11 +246,22 @@ static void *__videobuf_alloc(size_t size) if (vb) { mem = vb-priv = ((char *)vb) + size; mem-magic = MAGIC_DC_MEM; + mem-cached = cached; } return vb; } +static void *__videobuf_alloc_uncached(size_t size) +{ + return __videobuf_alloc(size, false); +} + +static void *__videobuf_alloc_cached(size_t size) +{ + return __videobuf_alloc(size, true); +} + static void *__videobuf_to_vmalloc(struct videobuf_buffer *buf
Re: [PATCH 1/2] media: Add timberdale video-in driver
On 04/25/2010 05:24 PM, Mauro Carvalho Chehab wrote: Richard Röjfors wrote: This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 videobuffers to handle buffers against user space. Due to some timing constraint it makes sense to do DMA into an intermediate buffer and then copy the data to vmalloc:ed buffers. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjforsrichard.rojf...@pelagicore.com +#define TIMBLOGIW_DMA_BUFFER_SIZE (TIMBLOGIW_BYTES_PER_LINE * 576) ... +static int __timblogiw_alloc_dma(struct timblogiw_fh *fh, struct device *dev) +{ + dma_addr_t addr; + int err, i, pos; + int bytes_per_desc = TIMBLOGIW_LINES_PER_DESC * + timblogiw_bytes_per_line(fh-cur_norm); + + fh-dma.cookie = -1; + fh-dma.dev = dev; + + fh-dma.buf = kzalloc(TIMBLOGIW_DMA_BUFFER_SIZE, GFP_KERNEL); + if (!fh-dma.buf) + return -ENOMEM; Why do you need a fixed DMA buffer size? Just allocate the buffer size dynamically at buffer_prepare callback. + videobuf_queue_vmalloc_init(fh-vb_vidq,timblogiw_video_qops, + NULL,fh-queue_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, + V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh); You should be using, instead, videobuf_dma_sg or videobuf_cont, instead of using videobuf-vmalloc. This way, you'll avoid double buffering. 1. dma_sg can not be used, the DMA engine requires the memory blocks to be aligned on a factor of bytes per line, so 4K pages wouldn't work. 2. I tried using videobuf-dma-contig, but got poor performance. I can not really explain why, I though it's due to the fact that the contiguous buffer is allocated coherent - no caching. I saw both gstreamer and mplayer perform very badly. The frame grabber requires the DMA transfer for a frame beeing started while the frame is decoded. When I tested using contigous buffers gstreamer sometimes was that slow that it sometimes missed to have a frame queued when a transfer was finished, so I got frame drops. Any other ideas of the poor performance? otherwise I would like to go for the double buffered solution. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2 v2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 videobuffers to handle buffers against user space. Due to some timing constraint it makes sense to do DMA into an intermediate buffer and then copy the data to vmalloc:ed buffers. If available the driver uses an encoder to get/set the video standard In addition to first version, the Makefile update is included in the patch Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f8fc865..ba895cc 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -949,6 +949,15 @@ config VIDEO_OMAP2 ---help--- This is a v4l2 driver for the TI OMAP2 camera capture interface +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_VMALLOC + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + # # USB Multimedia device configuration # diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index b88b617..4d5b6b8 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -164,6 +164,8 @@ obj-$(CONFIG_ARCH_DAVINCI) += davinci/ obj-$(CONFIG_VIDEO_AU0828) += au0828/ +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o + obj-$(CONFIG_USB_VIDEO_CLASS) += uvc/ obj-$(CONFIG_VIDEO_SAA7164) += saa7164/ diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..3f30ff6 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,920 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dma-mapping.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-vmalloc.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_BYTES_PER_LINE (720 * 2) +#define TIMBLOGIW_DMA_BUFFER_SIZE (TIMBLOGIW_BYTES_PER_LINE * 576) +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + struct tasklet_struct tasklet; + struct { + void*buf; + struct scatterlist sg[16]; + struct device *dev; + dma_cookie_tcookie; + } dma; + unsigned intframe_count; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std
[PATCH 2/2] mfd: Add timberdale video-in driver to timberdale
This patch defines platform data for the video-in driver and adds it to all configurations of timberdale. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 2d4691a..49aa733 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -40,6 +40,7 @@ #include linux/spi/mc33880.h #include media/timb_radio.h +#include media/timb_video.h #include linux/timb_dma.h @@ -238,6 +239,22 @@ const static __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; +static __devinitdata struct i2c_board_info timberdale_adv7180_i2c_board_info = { + /* Requires jumper JP9 to be off */ + I2C_BOARD_INFO(adv7180, 0x42 1), + .irq = IRQ_TIMBERDALE_ADV7180 +}; + +static __devinitdata struct timb_video_platform_data + timberdale_video_platform_data = { + .dma_channel = DMA_VIDEO_RX, + .i2c_adapter = 0, + .encoder = { + .module_name = adv7180, + .info = timberdale_adv7180_i2c_board_info + } +}; + const static __devinitconst struct resource timberdale_radio_resources[] = { { .start = RDSOFFSET, @@ -272,6 +289,18 @@ static __devinitdata struct timb_radio_platform_data } }; +const static __devinitconst struct resource timberdale_video_resources[] = { + { + .start = LOGIWOFFSET, + .end= LOGIWEND, + .flags = IORESOURCE_MEM, + }, + /* + note that the frame buffer is located in DMA area + starting at 0x120 + */ +}; + static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = { .nr_channels = 10, .channels = { @@ -372,6 +401,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -430,6 +466,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -478,6 +521,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, @@ -521,6 +571,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-video, + .num_resources = ARRAY_SIZE(timberdale_video_resources), + .resources = timberdale_video_resources, + .platform_data = timberdale_video_platform_data, + .data_size = sizeof(timberdale_video_platform_data), + }, + { .name = timb-radio, .num_resources = ARRAY_SIZE(timberdale_radio_resources), .resources = timberdale_radio_resources, -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] media, mfd: Add timberdale video-in driver
To follow are two patches. The first one adds the timberdale video-in driver to the media tree. The second one adds it to the timberdale MFD driver. The Kconfig of the media patch selects TIMB_DMA which is introduced in the DMA tree, that's why I cc:d in Dan. Samuel and Mauro hope you can support and solve the potential merge issue between your two trees. Thanks --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] media: Add timberdale video-in driver
This patch adds the timberdale video-in driver. The video IP of timberdale delivers the video data via DMA. The driver uses the DMA api to handle DMA transfers, and make use of the V4L2 videobuffers to handle buffers against user space. Due to some timing constraint it makes sense to do DMA into an intermediate buffer and then copy the data to vmalloc:ed buffers. If available the driver uses an encoder to get/set the video standard Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f8fc865..ba895cc 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -949,6 +949,15 @@ config VIDEO_OMAP2 ---help--- This is a v4l2 driver for the TI OMAP2 camera capture interface +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 I2C + select TIMB_DMA + select VIDEO_ADV7180 + select VIDEOBUF_VMALLOC + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + # # USB Multimedia device configuration # diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c new file mode 100644 index 000..3f30ff6 --- /dev/null +++ b/drivers/media/video/timblogiw.c @@ -0,0 +1,920 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009-2010 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/version.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/dma-mapping.h +#include linux/dmaengine.h +#include linux/scatterlist.h +#include linux/interrupt.h +#include linux/list.h +#include linux/i2c.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/videobuf-vmalloc.h +#include media/timb_video.h + +#define DRIVER_NAMEtimb-video + +#define TIMBLOGIWIN_NAME Timberdale Video-In +#define TIMBLOGIW_VERSION_CODE 0x04 + +#define TIMBLOGIW_BYTES_PER_LINE (720 * 2) +#define TIMBLOGIW_DMA_BUFFER_SIZE (TIMBLOGIW_BYTES_PER_LINE * 576) +#define TIMBLOGIW_LINES_PER_DESC 44 +#define TIMBLOGIW_MAX_VIDEO_MEM16 + +#define TIMBLOGIW_VIDEO_FORMAT V4L2_PIX_FMT_UYVY + +#define TIMBLOGIW_HAS_DECODER(lw) (lw-pdata.encoder.module_name) + + +struct timblogiw { + struct video_device video_dev; + struct v4l2_device v4l2_dev; /* mutual exclusion */ + struct mutexlock; + struct device *dev; + struct timb_video_platform_data pdata; + struct v4l2_subdev *sd_enc;/* encoder */ + boolopened; +}; + +struct timblogiw_tvnorm { + v4l2_std_id std; + u16 width; + u16 height; + u8 fps; +}; + +struct timblogiw_fh { + struct videobuf_queue vb_vidq; + struct timblogiw_tvnorm const *cur_norm; + struct list_headcapture; + struct dma_chan *chan; + spinlock_t queue_lock; /* mutual exclusion */ + struct tasklet_struct tasklet; + struct { + void*buf; + struct scatterlist sg[16]; + struct device *dev; + dma_cookie_tcookie; + } dma; + unsigned intframe_count; +}; + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .width = 720, + .height = 576, + .fps= 25 + }, + { + .std= V4L2_STD_NTSC, + .width = 720, + .height = 480, + .fps= 26 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm) +{ + return norm-width * 2; +} + + +static int timblogiw_frame_size(const struct timblogiw_tvnorm *norm) +{ + return norm-height * timblogiw_bytes_per_line(norm); +} + +static const struct timblogiw_tvnorm
Re: adv7180 as SoC camera device
On 2/22/10 5:01 PM, Rodolfo Giometti wrote: On Fri, Feb 19, 2010 at 08:36:38PM +0100, Guennadi Liakhovetski wrote: On Fri, 19 Feb 2010, Rodolfo Giometti wrote: Hello, on my pxa27x based board I have a adv7180 connected with the CIF interface. Due this fact I'm going to use the pxa_camera.c driver which in turn registers a soc_camera_host. In the latest kernel I found your driver for the ADV7180, but it registers the chip as a v4l sub device. I suppose these two interfaces are not compatible, aren't they? Congratulations! Thereby you're in a position to develop the first v4l2-subdev / soc-camera universal driver;) The answer to this your question is - they are... kinda. This means - yes, soc-camera is also using the v4l2-subdev API, but - with a couple of additions. Basically, there are two things you have to change in the adv7180 driver to make it compatible with soc-camera - (1) add bus-configuration methods, even if they don't do much (see .query_bus_param() and .set_bus_param() methods from struct soc_camera_ops), and (2) migrate the driver to the mediabus API. The latter one requires some care - in principle, mediabus should be the future API to negotiate parameters on the video bus between bridges (in your case PXA CIF) and clients, but for you this means you also have to migrate any other bridge drivers in the mainline to that API, and, if they also interface to some other subdevices - those too, and if those can also work with other bridges - those too...;) But, I think, that chain will terminate quite soon, in fact, I cannot find any users of that driver currently in the mainline, Richard? In this situation, should I write a new driver for the soc_camera_device? Which is The-Right-Thing(TM) to do? :) Please, have a look and try to convert the driver as described above. All the APIs and a few examples are in the mainline, so, you should have enough copy-paste sources;) Ask on the list (with me on cc) if anything is still unclear. Thanks for your quick answer! :) What I still don't understand is if should I move the driver form v4l2-subdev to a soc_camera device or trying to support both API... It seems to me that the driver is not used by any machines into mainline so if soc-camera is also using the v4l2-subdev API but with a couple of additions I suppose I can move it to soc_camera API... Is that right? We use it as a subdev to a driver not yet committed from us. So I think you should extend it, not move it. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] mfd: Add timb-radio to the timberdale MFD
On 02/19/2010 04:52 AM, Mauro Carvalho Chehab wrote: Richard Röjfors wrote: This patch addes timb-radio to all configurations of the timberdale MFD. Connected to the FPGA is a TEF6862 tuner and a SAA7706H DSP, the I2C board info of these devices is passed via the timb-radio platform data. Hi Richard, I'm trying to apply it to my git tree (http://git.linuxtv.org/v4l-dvb.git), but it is failing: Ah, this patch was against your linux-next.git at kernel.org. I will generate a new patch against the proper git. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] mfd: Add timb-radio to the timberdale MFD
On 02/19/2010 04:52 AM, Mauro Carvalho Chehab wrote: Richard Röjfors wrote: This patch addes timb-radio to all configurations of the timberdale MFD. Connected to the FPGA is a TEF6862 tuner and a SAA7706H DSP, the I2C board info of these devices is passed via the timb-radio platform data. Hi Richard, I'm trying to apply it to my git tree (http://git.linuxtv.org/v4l-dvb.git), but it is failing: Hi Mauro, Right now my mail client, icedove, confuses me. Just upgraded to ver 3. It seem to add in an extra space to lines not starting with a plus in the patch. I attached the patch. Sorry for the inconvenience. --Richard This patch addes timb-radio to all configurations of the timberdale MFD. Connected to the FPGA is a TEF6862 tuner and a SAA7706H DSP, the I2C board info of these devices is passed via the timb-radio platform data. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 603cf06..1ed44d2 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -37,6 +37,8 @@ #include linux/spi/max7301.h #include linux/spi/mc33880.h +#include media/timb_radio.h + #include timberdale.h #define DRIVER_NAME timberdale @@ -213,6 +215,40 @@ const static __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; +const static __devinitconst struct resource timberdale_radio_resources[] = { + { + .start = RDSOFFSET, + .end = RDSEND, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_TIMBERDALE_RDS, + .end = IRQ_TIMBERDALE_RDS, + .flags = IORESOURCE_IRQ, + }, +}; + +static __devinitdata struct i2c_board_info timberdale_tef6868_i2c_board_info = { + I2C_BOARD_INFO(tef6862, 0x60) +}; + +static __devinitdata struct i2c_board_info timberdale_saa7706_i2c_board_info = { + I2C_BOARD_INFO(saa7706h, 0x1C) +}; + +static __devinitdata struct timb_radio_platform_data + timberdale_radio_platform_data = { + .i2c_adapter = 0, + .tuner = { + .module_name = tef6862, + .info = timberdale_tef6868_i2c_board_info + }, + .dsp = { + .module_name = saa7706h, + .info = timberdale_saa7706_i2c_board_info + } +}; + const static __devinitconst struct resource timberdale_dma_resources[] = { { .start = DMAOFFSET, @@ -240,6 +276,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -282,6 +325,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -314,6 +364,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -348,6 +405,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources,
Re: [PATCH] mfd: Add timb-radio to the timberdale MFD
On 02/19/2010 03:56 PM, Randy Dunlap wrote: On 02/19/10 14:41, Richard Röjfors wrote: On 02/19/2010 04:52 AM, Mauro Carvalho Chehab wrote: Richard Röjfors wrote: This patch addes timb-radio to all configurations of the timberdale MFD. Connected to the FPGA is a TEF6862 tuner and a SAA7706H DSP, the I2C board info of these devices is passed via the timb-radio platform data. Hi Richard, I'm trying to apply it to my git tree (http://git.linuxtv.org/v4l-dvb.git), but it is failing: Hi Mauro, Right now my mail client, icedove, confuses me. Just upgraded to ver 3. It seem to add in an extra space to lines not starting with a plus in the patch. I had that problem with something called Thunderbird. Perhaps you could use the hints in Documentation/email-clients.txt but change Thunderbird to icedove. (?) icedove is debians fork of thunderbird, so I think it's basically the same client. So if people using it isn't aware of it I think we should change it to Thunderbird/Icedove in the documentation --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] mfd: Add timb-radio to the timberdale MFD
This patch addes timb-radio to all configurations of the timberdale MFD. Connected to the FPGA is a TEF6862 tuner and a SAA7706H DSP, the I2C board info of these devices is passed via the timb-radio platform data. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 603cf06..1ed44d2 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -37,6 +37,8 @@ #include linux/spi/max7301.h #include linux/spi/mc33880.h +#include media/timb_radio.h + #include timberdale.h #define DRIVER_NAME timberdale @@ -213,6 +215,40 @@ const static __devinitconst struct resource timberdale_uartlite_resources[] = { }, }; +const static __devinitconst struct resource timberdale_radio_resources[] = { + { + .start = RDSOFFSET, + .end= RDSEND, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_TIMBERDALE_RDS, + .end= IRQ_TIMBERDALE_RDS, + .flags = IORESOURCE_IRQ, + }, +}; + +static __devinitdata struct i2c_board_info timberdale_tef6868_i2c_board_info = { + I2C_BOARD_INFO(tef6862, 0x60) +}; + +static __devinitdata struct i2c_board_info timberdale_saa7706_i2c_board_info = { + I2C_BOARD_INFO(saa7706h, 0x1C) +}; + +static __devinitdata struct timb_radio_platform_data + timberdale_radio_platform_data = { + .i2c_adapter = 0, + .tuner = { + .module_name = tef6862, + .info = timberdale_tef6868_i2c_board_info + }, + .dsp = { + .module_name = saa7706h, + .info = timberdale_saa7706_i2c_board_info + } +}; + const static __devinitconst struct resource timberdale_dma_resources[] = { { .start = DMAOFFSET, @@ -240,6 +276,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -282,6 +325,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = { .resources = timberdale_mlogicore_resources, }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -314,6 +364,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, @@ -348,6 +405,13 @@ static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = { .data_size = sizeof(timberdale_gpio_platform_data), }, { + .name = timb-radio, + .num_resources = ARRAY_SIZE(timberdale_radio_resources), + .resources = timberdale_radio_resources, + .platform_data = timberdale_radio_platform_data, + .data_size = sizeof(timberdale_radio_platform_data), + }, + { .name = xilinx_spi, .num_resources = ARRAY_SIZE(timberdale_spi_resources), .resources = timberdale_spi_resources, -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] mfd: Add support for the timberdale FPGA.
On 2/4/10 10:28 AM, Samuel Ortiz wrote: On Wed, Feb 03, 2010 at 05:23:57PM +, Mauro Carvalho Chehab wrote: Ok, thanks again for your understanding. This is definitely material for the next merge window, so I'll merge it into my for-next branch. The last version of the driver is OK for merging. However, I noticed one issue: it depends on two drivers that were already merged on my tree: +config RADIO_TIMBERDALE + tristate Enable the Timberdale radio driver + depends on MFD_TIMBERDALE VIDEO_V4L2 + select RADIO_TEF6862 + select RADIO_SAA7706H Currently, the dependency seems to happen only at Kconfig level. Maybe the better is to return to the previous plan: apply it via my tree, as the better is to have it added after those two radio i2c drivers. I'm fine with that. Richard sent me a 2nd version of his patch that I was about to merge. Richard, could you please post this patch here, or to lkml with Mauro cc'ed ? I'll add my SOB to it and then it will go through Mauro's tree. Now when the radio driver made it into the media tree, can I post an updated MFD which defines these drivers too? Is a complete MFD patch preferred, or just an incremental against the last one? --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/1] mfd: Add support for the timberdale FPGA.
Hi, To follow is the timberdale patch (again), to sort out the merging as pointed out by Mauro and Samuel. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/1] mfd: Add support for the timberdale FPGA.
The timberdale FPGA is found on the Intel in-Vehicle Infotainment reference board russelville. The driver is a PCI driver which chunks up the I/O memory and distributes interrupts to a number of platform devices for each IP inside the FPGA. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 8782978..f92673b 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -348,6 +348,17 @@ config AB4500_CORE read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config MFD_TIMBERDALE + tristate Support for the Timberdale FPGA + select MFD_CORE + depends on PCI + ---help--- + This is the core driver for the timberdale FPGA. This device is a + multifunction device which exposes numerous platform devices. + + The timberdale FPGA can be found on the Intel Atom development board + for in-vehicle infontainment, called Russellville. + endmenu menu Multimedia Capabilities Port drivers diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index e09eb48..53375ac 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -55,4 +55,6 @@ obj-$(CONFIG_AB3100_CORE) += ab3100-core.o obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE)+= ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o + +obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c new file mode 100644 index 000..603cf06 --- /dev/null +++ b/drivers/mfd/timberdale.c @@ -0,0 +1,663 @@ +/* + * timberdale.c timberdale FPGA MFD driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/pci.h +#include linux/msi.h +#include linux/mfd/core.h + +#include linux/timb_gpio.h + +#include linux/i2c.h +#include linux/i2c-ocores.h +#include linux/i2c/tsc2007.h + +#include linux/spi/spi.h +#include linux/spi/xilinx_spi.h +#include linux/spi/max7301.h +#include linux/spi/mc33880.h + +#include timberdale.h + +#define DRIVER_NAME timberdale + +struct timberdale_device { + resource_size_t ctl_mapbase; + unsigned char __iomem *ctl_membase; + struct { + u32 major; + u32 minor; + u32 config; + } fw; +}; + +/*--*/ + +static struct tsc2007_platform_data timberdale_tsc2007_platform_data = { + .model = 2003, + .x_plate_ohms = 100 +}; + +static struct i2c_board_info timberdale_i2c_board_info[] = { + { + I2C_BOARD_INFO(tsc2007, 0x48), + .platform_data = timberdale_tsc2007_platform_data, + .irq = IRQ_TIMBERDALE_TSC_INT + }, +}; + +static __devinitdata struct ocores_i2c_platform_data +timberdale_ocores_platform_data = { + .regstep = 4, + .clock_khz = 62500, + .devices = timberdale_i2c_board_info, + .num_devices = ARRAY_SIZE(timberdale_i2c_board_info) +}; + +const static __devinitconst struct resource timberdale_ocores_resources[] = { + { + .start = OCORESOFFSET, + .end= OCORESEND, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_TIMBERDALE_I2C, + .end= IRQ_TIMBERDALE_I2C, + .flags = IORESOURCE_IRQ, + }, +}; + +const struct max7301_platform_data timberdale_max7301_platform_data = { + .base = 200 +}; + +const struct mc33880_platform_data timberdale_mc33880_platform_data = { + .base = 100 +}; + +static struct spi_board_info timberdale_spi_16bit_board_info[] = { + { + .modalias = max7301, + .max_speed_hz = 26000, + .chip_select = 2, + .mode = SPI_MODE_0, + .platform_data = timberdale_max7301_platform_data + }, +}; + +static struct spi_board_info timberdale_spi_8bit_board_info[] = { + { + .modalias = mc33880
Re: [PATCH] mfd: Add support for the timberdale FPGA.
On 02/03/2010 10:16 AM, Mauro Carvalho Chehab wrote: Hi Richard, Richard Röjfors wrote: The timberdale FPGA is found on the Intel in-Vehicle Infotainment reference board russelville. The driver is a PCI driver which chunks up the I/O memory and distributes interrupts to a number of platform devices for each IP inside the FPGA. Signed-off-by: Richard Röjforsrichard.rojf...@pelagicore.com I'm not sure how to deal with this patch. It doesn't contain anything related to V4L2 inside it, nor it applies to drivers/media, Sorry my address book tricked me. I was suppose to send it to LKML not the Media mailing list. I will resend the patch with the correct addresses in it. but it depends on the radio-timb driver that you submitted us. Actually this MFD has more devices than in the current patch. These will be incrementally added when the corresponding drivers goes into the kernel. Sorry for the inconvenience. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/1] radio: Add radio-timb
On the intel russellville board there is a radio DSP, radio tuner and a RDS block. This umbrella driver uses two subdevs (DSP and tuner). Since v2, the RDS support has been removed from the patch. The current API in V4L2 and the simplicity of the Radio DSP makes it a bit complicated to implement the RDS support properly. It will be added at a later stage. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/1] radio: Add radio-timb
This patch add supports for the radio system on the Intel Russellville board. It's a In-Vehicle Infotainment board with a radio tuner and DSP. This umbrella driver has the DSP and tuner as V4L2 subdevs and calls them when needed. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 3f40f37..c242939 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -429,4 +429,14 @@ config RADIO_TEF6862 To compile this driver as a module, choose M here: the module will be called TEF6862. +config RADIO_TIMBERDALE + tristate Enable the Timberdale radio driver + depends on MFD_TIMBERDALE VIDEO_V4L2 + select RADIO_TEF6862 + select RADIO_SAA7706H + ---help--- + This is a kind of umbrella driver for the Radio Tuner and DSP + found behind the Timberdale FPGA on the Russellville board. + Enabling this driver will automatically select the DSP and tuner. + endif # RADIO_ADAPTERS diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 01922ad..8973850 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -24,5 +24,6 @@ obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o obj-$(CONFIG_RADIO_TEF6862) += tef6862.o +obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o EXTRA_CFLAGS += -Isound diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c new file mode 100644 index 000..c650865 --- /dev/null +++ b/drivers/media/radio/radio-timb.c @@ -0,0 +1,260 @@ +/* + * radio-timb.c Timberdale FPGA Radio driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/version.h +#include linux/io.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include linux/platform_device.h +#include linux/interrupt.h +#include linux/i2c.h +#include media/timb_radio.h + +#define DRIVER_NAME timb-radio + +struct timbradio { + struct timb_radio_platform_data pdata; + struct v4l2_subdev *sd_tuner; + struct v4l2_subdev *sd_dsp; + struct video_device *video_dev; + struct v4l2_device v4l2_dev; +}; + + +static int timbradio_vidioc_querycap(struct file *file, void *priv, + struct v4l2_capability *v) +{ + strlcpy(v-driver, DRIVER_NAME, sizeof(v-driver)); + strlcpy(v-card, Timberdale Radio, sizeof(v-card)); + snprintf(v-bus_info, sizeof(v-bus_info), platform:DRIVER_NAME); + v-version = KERNEL_VERSION(0, 0, 1); + v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + return 0; +} + +static int timbradio_vidioc_g_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ + struct timbradio *tr = video_drvdata(file); + return v4l2_subdev_call(tr-sd_tuner, tuner, g_tuner, v); +} + +static int timbradio_vidioc_s_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ + struct timbradio *tr = video_drvdata(file); + return v4l2_subdev_call(tr-sd_tuner, tuner, s_tuner, v); +} + +static int timbradio_vidioc_g_input(struct file *filp, void *priv, + unsigned int *i) +{ + *i = 0; + return 0; +} + +static int timbradio_vidioc_s_input(struct file *filp, void *priv, + unsigned int i) +{ + return i ? -EINVAL : 0; +} + +static int timbradio_vidioc_g_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ + a-index = 0; + strlcpy(a-name, Radio, sizeof(a-name)); + a-capability = V4L2_AUDCAP_STEREO; + return 0; +} + + +static int timbradio_vidioc_s_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ + return a-index ? -EINVAL : 0; +} + +static int timbradio_vidioc_s_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) +{ + struct timbradio *tr = video_drvdata(file); + return v4l2_subdev_call(tr-sd_tuner, tuner, s_frequency, f); +} + +static int timbradio_vidioc_g_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) +{ + struct timbradio *tr = video_drvdata(file); + return v4l2_subdev_call(tr-sd_tuner, tuner, g_frequency, f); +} + +static int timbradio_vidioc_queryctrl(struct file *file, void *priv
[PATCH] mfd: Add support for the timberdale FPGA.
The timberdale FPGA is found on the Intel in-Vehicle Infotainment reference board russelville. The driver is a PCI driver which chunks up the I/O memory and distributes interrupts to a number of platform devices for each IP inside the FPGA. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 8782978..f92673b 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -348,6 +348,17 @@ config AB4500_CORE read/write functions for the devices to get access to this chip. This chip embeds various other multimedia funtionalities as well. +config MFD_TIMBERDALE + tristate Support for the Timberdale FPGA + select MFD_CORE + depends on PCI + ---help--- + This is the core driver for the timberdale FPGA. This device is a + multifunction device which exposes numerous platform devices. + + The timberdale FPGA can be found on the Intel Atom development board + for in-vehicle infontainment, called Russellville. + endmenu menu Multimedia Capabilities Port drivers diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index e09eb48..53375ac 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -55,4 +55,6 @@ obj-$(CONFIG_AB3100_CORE) += ab3100-core.o obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o -obj-$(CONFIG_PMIC_ADP5520) += adp5520.o \ No newline at end of file +obj-$(CONFIG_PMIC_ADP5520) += adp5520.o + +obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c new file mode 100644 index 000..90f745b --- /dev/null +++ b/drivers/mfd/timberdale.c @@ -0,0 +1,667 @@ +/* + * timberdale.c timberdale FPGA MFD driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/pci.h +#include linux/msi.h +#include linux/mfd/core.h + +#include linux/timb_gpio.h + +#include linux/i2c.h +#include linux/i2c-ocores.h +#include linux/i2c/tsc2007.h + +#include linux/spi/spi.h +#include linux/spi/xilinx_spi.h +#include linux/spi/max7301.h +#include linux/spi/mc33880.h + +#include timberdale.h + +#define DRIVER_NAME timberdale + +struct timberdale_device { + resource_size_t ctl_mapbase; + unsigned char __iomem *ctl_membase; + struct { + u32 major; + u32 minor; + u32 config; + } fw; +}; + +/*--*/ + +static struct tsc2007_platform_data timberdale_tsc2007_platform_data = { + .model = 2003, + .x_plate_ohms = 100 +}; + +static struct i2c_board_info timberdale_i2c_board_info[] = { + { + I2C_BOARD_INFO(tsc2007, 0x48), + .platform_data = timberdale_tsc2007_platform_data, + .irq = IRQ_TIMBERDALE_TSC_INT + }, +}; + +static __devinitdata struct ocores_i2c_platform_data +timberdale_ocores_platform_data = { + .regstep = 4, + .clock_khz = 62500, + .devices = timberdale_i2c_board_info, + .num_devices = ARRAY_SIZE(timberdale_i2c_board_info) +}; + +const static __devinitconst struct resource timberdale_ocores_resources[] = { + { + .start = OCORESOFFSET, + .end= OCORESEND, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_TIMBERDALE_I2C, + .end= IRQ_TIMBERDALE_I2C, + .flags = IORESOURCE_IRQ, + }, +}; + +const struct max7301_platform_data timberdale_max7301_platform_data = { + .base = 200 +}; + +const struct mc33880_platform_data timberdale_mc33880_platform_data = { + .base = 100 +}; + +static struct spi_board_info timberdale_spi_16bit_board_info[] = { + { + .modalias = max7301, + .max_speed_hz = 26000, + .chip_select = 2, + .mode = SPI_MODE_0, + .platform_data = timberdale_max7301_platform_data + }, +}; + +static struct spi_board_info timberdale_spi_8bit_board_info[] = { + { + .modalias = mc33880, + .max_speed_hz
Re: [PATCH 1/2] radio: Add radio-timb
Hans Verkuil wrote: The first time we run we could definitely do a 4l2_i2c_new_subdev*, but what if I rmmod the driver and insmod it again? When we do the do an open, then v4l2_i2c_new_subdev* would fail because the device is only on the bus and probed. So I would have to look for it anyway. Or am I wrong? I found this like the only generic way(?) Not sure I understand you. When you call v4l2_device_unregister any registered i2c devices will be automatically unloaded from the i2c bus. So when you do a new modprobe, then it is as if you did it for the first time. This should work. If not, then let me know and we can look at it. Thanks for the explanation! It should work, I will update accordingly. Is there a reason why you want to load them only on first use? It is customary to load them when this driver is loaded. Exceptions to that may be if the i2c device needs to load a firmware: this can be slow over i2c and so should be postponed until the i2c driver is needed for the first time. The main reason is actually that this is a platform device which might come available before the I2C bus in the system. So we postpone the use of the bus until needed, because we know for sure it's available at that point. The i2c busses are always initialized first. That's a change that went in a few kernel releases ago. Ok, in this case the I2C bus sits on top of a MFD device which might be installed late to reduce bootup time. Bootup time is actually also a reason to keep this code in open rather than in probe. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/3] radio: Add support for SAA7706H Car Radio DSP
These sets of patches added support for the SAA7706H Car Radio DSP. Patch 2 is updated after feedback from Hans Verkuil. Thanks Hans! Patch 1: Add The saa7706h to the v4l2-chip-ident.h Patch 2: Add the actual source code Patch 3: Add the saa7706h to the Kconfig and Makefile --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] radio: Add SAA7706H to Kconfig and Makefile
This patch adds the SAA7706H to Kconfig and Makefile, it points out the source code added in the previous patch. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 3f40f37..1716e52 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -417,6 +417,18 @@ config RADIO_TEA5764_XTAL Say Y here if TEA5764 have a 32768 Hz crystal in circuit, say N here if TEA5764 reference frequency is connected in FREQIN. +config RADIO_SAA7706H + tristate SAA7706H Car Radio DSP + depends on I2C VIDEO_V4L2 + ---help--- + Say Y here if you want to use the SAA7706H Car radio Digital + Signal Processor, found for instance on the Russellville development + board. On the russellville the device is connected to internal + timberdale I2C bus. + + To compile this driver as a module, choose M here: the + module will be called SAA7706H. + config RADIO_TEF6862 tristate TEF6862 Car Radio Enhanced Selectivity Tuner depends on I2C VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 01922ad..f681dbf 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o +obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o obj-$(CONFIG_RADIO_TEF6862) += tef6862.o EXTRA_CFLAGS += -Isound -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/3] radio: Add support for SAA7706H Car Radio DSP
This patch contains initial support for the SAA7706H Car Radio DSP. It is a I2C device and currently the mute control is supported. When the device is unmuted it is brought out of reset and initiated using the proposed intialisation sequence. When muted the DSP is brought into reset state. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c new file mode 100644 index 000..3396f8f --- /dev/null +++ b/drivers/media/radio/saa7706h.c @@ -0,0 +1,450 @@ +/* + * saa7706.c Philips SAA7706H Car Radio DSP driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h + +#define DRIVER_NAME saa7706h + +/* the I2C memory map looks like this + + $1C00 - $ Not Used + $2200 - $3FFF Reserved YRAM (DSP2) space + $2000 - $21FF YRAM (DSP2) + $1FF0 - $1FFF Hardware Registers + $1280 - $1FEF Reserved XRAM (DSP2) space + $1000 - $127F XRAM (DSP2) + $0FFFDSP CONTROL + $0A00 - $0FFE Reserved + $0980 - $09FF Reserved YRAM (DSP1) space + $0800 - $097F YRAM (DSP1) + $0200 - $07FF Not Used + $0180 - $01FF Reserved XRAM (DSP1) space + $ - $017F XRAM (DSP1) +*/ + +#define SAA7706H_REG_CTRL 0x0fff +#define SAA7706H_CTRL_BYP_PLL 0x0001 +#define SAA7706H_CTRL_PLL_DIV_MASK 0x003e +#define SAA7706H_CTRL_PLL3_62975MHZ0x003e +#define SAA7706H_CTRL_DSP_TURBO0x0040 +#define SAA7706H_CTRL_PC_RESET_DSP10x0080 +#define SAA7706H_CTRL_PC_RESET_DSP20x0100 +#define SAA7706H_CTRL_DSP1_ROM_EN_MASK 0x0600 +#define SAA7706H_CTRL_DSP1_FUNC_PROM 0x +#define SAA7706H_CTRL_DSP2_ROM_EN_MASK 0x1800 +#define SAA7706H_CTRL_DSP2_FUNC_PROM 0x +#define SAA7706H_CTRL_DIG_SIL_INTERPOL 0x8000 + +#define SAA7706H_REG_EVALUATION0x1ff0 +#define SAA7706H_EVAL_DISABLE_CHARGE_PUMP 0x01 +#define SAA7706H_EVAL_DCS_CLOCK0x02 +#define SAA7706H_EVAL_GNDRC1_ENABLE0x04 +#define SAA7706H_EVAL_GNDRC2_ENABLE0x08 + +#define SAA7706H_REG_CL_GEN1 0x1ff3 +#define SAA7706H_CL_GEN1_MIN_LOOPGAIN_MASK 0x0f +#define SAA7706H_CL_GEN1_LOOPGAIN_MASK 0xf0 +#define SAA7706H_CL_GEN1_COARSE_RATION 0x00 + +#define SAA7706H_REG_CL_GEN2 0x1ff4 +#define SAA7706H_CL_GEN2_WSEDGE_FALLING0x01 +#define SAA7706H_CL_GEN2_STOP_VCO 0x02 +#define SAA7706H_CL_GEN2_FRERUN0x04 +#define SAA7706H_CL_GEN2_ADAPTIVE 0x08 +#define SAA7706H_CL_GEN2_FINE_RATIO_MASK 0x00 + +#define SAA7706H_REG_CL_GEN4 0x1ff6 +#define SAA7706H_CL_GEN4_BYPASS_PLL1 0x001000 +#define SAA7706H_CL_GEN4_PLL1_DIV_MASK 0x03e000 +#define SAA7706H_CL_GEN4_DSP1_TURBO0x04 + +#define SAA7706H_REG_SEL 0x1ff7 +#define SAA7706H_SEL_DSP2_SRCA_MASK0x07 +#define SAA7706H_SEL_DSP2_FMTA_MASK0x31 +#define SAA7706H_SEL_DSP2_SRCB_MASK0x0001c0 +#define SAA7706H_SEL_DSP2_FMTB_MASK0x000e00 +#define SAA7706H_SEL_DSP1_SRC_MASK 0x003000 +#define SAA7706H_SEL_DSP1_FMT_MASK 0x01c003 +#define SAA7706H_SEL_SPDIF20x02 +#define SAA7706H_SEL_HOST_IO_FMT_MASK 0x1c +#define SAA7706H_SEL_EN_HOST_IO0x20 + +#define SAA7706H_REG_IAC 0x1ff8 +#define SAA7706H_REG_CLK_SET 0x1ff9 +#define SAA7706H_REG_CLK_COEFF 0x1ffa +#define SAA7706H_REG_INPUT_SENS0x1ffb +#define SAA7706H_INPUT_SENS_RDS_VOL_MASK 0x0003f +#define SAA7706H_INPUT_SENS_FM_VOL_MASK0x00fc0 +#define SAA7706H_INPUT_SENS_FM_MPX 0x01000 +#define SAA7706H_INPUT_SENS_OFF_FILTER_A_EN0x02000 +#define SAA7706H_INPUT_SENS_OFF_FILTER_B_EN0x04000 +#define SAA7706H_REG_PHONE_NAV_AUDIO 0x1ffc +#define SAA7706H_REG_IO_CONF_DSP2 0x1ffd +#define SAA7706H_REG_STATUS_DSP2 0x1ffe +#define SAA7706H_REG_PC_DSP2 0x1fff + +#define SAA7706H_DSP1_MOD0 0x0800 +#define SAA7706H_DSP1_ROM_VER 0x097f
[PATCH 0/2] radio: Add radio-timb
On the intel russellville board there is a radio DSP, radio tuner and a RDS block. This umbrella driver uses two subdevs (DSP and tuner), and reads RDS data. Patch1: The actual code Patch2: Add the radio-timb to Kconfig and Makefile --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] radio: Add radio-timb
This patch add supports for the radio system on the Intel Russellville board. It's a In-Vehicle Infotainment board with a radio tuner and DSP. This umbrella driver has the DSP and tuner as V4L2 subdevs and calls them when needed. The RDS support is done by I/O memory accesses. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c new file mode 100644 index 000..3dbe9ad --- /dev/null +++ b/drivers/media/radio/radio-timb.c @@ -0,0 +1,543 @@ +/* + * radio-timb.c Timberdale FPGA Radio driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/version.h +#include linux/module.h +#include linux/io.h +#include media/v4l2-common.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include linux/platform_device.h +#include linux/interrupt.h +#include linux/i2c.h +#include media/timb_radio.h + +#define DRIVER_NAME timb-radio + +#define RDS_BLOCK_SIZE 4 +#define RDS_BUFFER_SIZE (RDS_BLOCK_SIZE * 100) + +struct timbradio { + struct mutexlock; /* for mutual exclusion */ + void __iomem*membase; + struct timb_radio_platform_data pdata; + struct v4l2_subdev *sd_tuner; + struct module *tuner_owner; + struct v4l2_subdev *sd_dsp; + struct module *dsp_owner; + struct video_device *video_dev; + /* RDS related */ + int open_count; + int rds_irq; + wait_queue_head_t read_queue; + unsigned char buffer[RDS_BUFFER_SIZE]; + unsigned int rd_index; + unsigned int wr_index; +}; + + +static int timbradio_vidioc_querycap(struct file *file, void *priv, + struct v4l2_capability *v) +{ + strlcpy(v-driver, DRIVER_NAME, sizeof(v-driver)); + strlcpy(v-card, Timberdale Radio, sizeof(v-card)); + snprintf(v-bus_info, sizeof(v-bus_info), platform:DRIVER_NAME); + v-version = KERNEL_VERSION(0, 0, 1); + v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + return 0; +} + +static int timbradio_vidioc_g_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ + struct timbradio *tr = video_drvdata(file); + int ret; + + mutex_lock(tr-lock); + ret = v4l2_subdev_call(tr-sd_tuner, tuner, g_tuner, v); + mutex_unlock(tr-lock); + + return ret; +} + +static int timbradio_vidioc_s_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ + struct timbradio *tr = video_drvdata(file); + int ret; + + mutex_lock(tr-lock); + ret = v4l2_subdev_call(tr-sd_tuner, tuner, s_tuner, v); + mutex_unlock(tr-lock); + + return ret; +} + +static int timbradio_vidioc_g_input(struct file *filp, void *priv, + unsigned int *i) +{ + *i = 0; + return 0; +} + +static int timbradio_vidioc_s_input(struct file *filp, void *priv, + unsigned int i) +{ + return i ? -EINVAL : 0; +} + +static int timbradio_vidioc_g_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ + a-index = 0; + strlcpy(a-name, Radio, sizeof(a-name)); + a-capability = V4L2_AUDCAP_STEREO; + return 0; +} + + +static int timbradio_vidioc_s_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ + return a-index ? -EINVAL : 0; +} + +static int timbradio_vidioc_s_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) +{ + struct timbradio *tr = video_drvdata(file); + int ret; + + mutex_lock(tr-lock); + ret = v4l2_subdev_call(tr-sd_tuner, tuner, s_frequency, f); + mutex_unlock(tr-lock); + + return ret; +} + +static int timbradio_vidioc_g_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) +{ + struct timbradio *tr = video_drvdata(file); + int ret; + + mutex_lock(tr-lock); + ret = v4l2_subdev_call(tr-sd_tuner, tuner, g_frequency, f); + mutex_unlock(tr-lock); + + return ret; +} + +static int timbradio_vidioc_queryctrl(struct file *file, void *priv, +struct v4l2_queryctrl *qc) +{ + struct timbradio *tr = video_drvdata
[PATCH 2/2] radio: Add radio-timb to the Kconfig and Makefile
This patch adds radio-timb to the Makefile and Kconfig. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 3f40f37..032ae2b 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -429,4 +429,14 @@ config RADIO_TEF6862 To compile this driver as a module, choose M here: the module will be called TEF6862. +config RADIO_TIMBERDALE + tristate Enable the Timberdale radio driver + depends on MFD_TIMBERDALE HAS_IOMEM + select RADIO_TEF6862 + select RADIO_SAA7706H + ---help--- + This is a kind of umbrella driver for the Radio Tuner and DSP + found behind the Timberdale FPGA on the Russellville board. + Enable this driver will automatically select the DSP and tuner. + endif # RADIO_ADAPTERS diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 01922ad..8973850 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -24,5 +24,6 @@ obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o obj-$(CONFIG_RADIO_TEF6862) += tef6862.o +obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o EXTRA_CFLAGS += -Isound -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] radio: Add radio-timb
Hans Verkuil wrote: On Friday 22 January 2010 13:38:28 Richard Röjfors wrote: This patch add supports for the radio system on the Intel Russellville board. It's a In-Vehicle Infotainment board with a radio tuner and DSP. This umbrella driver has the DSP and tuner as V4L2 subdevs and calls them when needed. The RDS support is done by I/O memory accesses. I gather from this source that you weren't aware of the RDS interface specification: http://www.linuxtv.org/downloads/v4l-dvb-apis/ch04s11.html Please use the V4L2_CAP_RDS_CAPTURE capability in querycap and use the struct v4l2_rds_data when reading the RDS data. Let us know if you run into problems doing this. This API was only formalized in 2.6.32 (although based on previous implementations), so it is pretty recent. Thanks, I'll look into this. I like the idea of harmonising the RDS API. The driver is actually older than 2.6.32 so I wasn't aware of it. Some more comments below. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c new file mode 100644 index 000..3dbe9ad --- /dev/null +++ b/drivers/media/radio/radio-timb.c @@ -0,0 +1,543 @@ +/* + * radio-timb.c Timberdale FPGA Radio driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/version.h +#include linux/module.h +#include linux/io.h +#include media/v4l2-common.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include linux/platform_device.h +#include linux/interrupt.h +#include linux/i2c.h +#include media/timb_radio.h + +#define DRIVER_NAME timb-radio + +#define RDS_BLOCK_SIZE 4 +#define RDS_BUFFER_SIZE (RDS_BLOCK_SIZE * 100) + +struct timbradio { +struct mutexlock; /* for mutual exclusion */ +void __iomem*membase; +struct timb_radio_platform_data pdata; +struct v4l2_subdev *sd_tuner; +struct module *tuner_owner; +struct v4l2_subdev *sd_dsp; +struct module *dsp_owner; +struct video_device *video_dev; +/* RDS related */ +int open_count; +int rds_irq; +wait_queue_head_t read_queue; +unsigned char buffer[RDS_BUFFER_SIZE]; +unsigned int rd_index; +unsigned int wr_index; +}; + + +static int timbradio_vidioc_querycap(struct file *file, void *priv, +struct v4l2_capability *v) +{ +strlcpy(v-driver, DRIVER_NAME, sizeof(v-driver)); +strlcpy(v-card, Timberdale Radio, sizeof(v-card)); +snprintf(v-bus_info, sizeof(v-bus_info), platform:DRIVER_NAME); +v-version = KERNEL_VERSION(0, 0, 1); +v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; +return 0; +} + +static int timbradio_vidioc_g_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ +struct timbradio *tr = video_drvdata(file); +int ret; + +mutex_lock(tr-lock); +ret = v4l2_subdev_call(tr-sd_tuner, tuner, g_tuner, v); +mutex_unlock(tr-lock); I'm not sure whether it is appropriate (or even needed!) to do the locking here. Perhaps it is better to do the locking in the tuner driver? This is just an idea. I do not have the datasheets, so I don't know what is reasonable here. + +return ret; +} + +static int timbradio_vidioc_s_tuner(struct file *file, void *priv, + struct v4l2_tuner *v) +{ +struct timbradio *tr = video_drvdata(file); +int ret; + +mutex_lock(tr-lock); +ret = v4l2_subdev_call(tr-sd_tuner, tuner, s_tuner, v); +mutex_unlock(tr-lock); + +return ret; +} + +static int timbradio_vidioc_g_input(struct file *filp, void *priv, +unsigned int *i) +{ +*i = 0; +return 0; +} + +static int timbradio_vidioc_s_input(struct file *filp, void *priv, +unsigned int i) +{ +return i ? -EINVAL : 0; +} + +static int timbradio_vidioc_g_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ +a-index = 0; +strlcpy(a-name, Radio, sizeof(a-name)); +a-capability = V4L2_AUDCAP_STEREO; +return 0; +} + + +static int timbradio_vidioc_s_audio(struct file *file, void *priv, + struct v4l2_audio *a) +{ +return
[PATCH 1/3] radio: Add the SAA7706H Car Radio DSP to v4l2-chip-ident.h
This patch add the SAA7706h to the v4l2-chip-ident.h Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h index 6cc107d..5341e3d 100644 --- a/include/media/v4l2-chip-ident.h +++ b/include/media/v4l2-chip-ident.h @@ -155,6 +155,9 @@ enum { /* module adv7343: just ident 7343 */ V4L2_IDENT_ADV7343 = 7343, + /* module saa7706h: just ident 7706 */ + V4L2_IDENT_SAA7706H = 7706, + /* module wm8739: just ident 8739 */ V4L2_IDENT_WM8739 = 8739, -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] radio: Add support for SAA7706H Car Radio DSP
This patch contains initial support for the SAA7706H Car Radio DSP. It is a I2C device and currently the mute control is supported. When the device is unmuted it is brought out of reset and initiated using the proposed intialisation sequence. When muted the DSP is brought into reset state. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c new file mode 100644 index 000..278de06 --- /dev/null +++ b/drivers/media/radio/saa7706h.c @@ -0,0 +1,491 @@ +/* + * saa7706.c Philips SAA7706H Car Radio DSP driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include linux/i2c-id.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h + +#define DRIVER_NAME saa7706h + +/* the I2C memory map looks like this + + $1C00 - $ Not Used + $2200 - $3FFF Reserved YRAM (DSP2) space + $2000 - $21FF YRAM (DSP2) + $1FF0 - $1FFF Hardware Registers + $1280 - $1FEF Reserved XRAM (DSP2) space + $1000 - $127F XRAM (DSP2) + $0FFFDSP CONTROL + $0A00 - $0FFE Reserved + $0980 - $09FF Reserved YRAM (DSP1) space + $0800 - $097F YRAM (DSP1) + $0200 - $07FF Not Used + $0180 - $01FF Reserved XRAM (DSP1) space + $ - $017F XRAM (DSP1) +*/ + +#define SAA7706H_REG_CTRL 0x0fff +#define SAA7706H_CTRL_BYP_PLL 0x0001 +#define SAA7706H_CTRL_PLL_DIV_MASK 0x003e +#define SAA7706H_CTRL_PLL3_62975MHZ0x003e +#define SAA7706H_CTRL_DSP_TURBO0x0040 +#define SAA7706H_CTRL_PC_RESET_DSP10x0080 +#define SAA7706H_CTRL_PC_RESET_DSP20x0100 +#define SAA7706H_CTRL_DSP1_ROM_EN_MASK 0x0600 +#define SAA7706H_CTRL_DSP1_FUNC_PROM 0x +#define SAA7706H_CTRL_DSP2_ROM_EN_MASK 0x1800 +#define SAA7706H_CTRL_DSP2_FUNC_PROM 0x +#define SAA7706H_CTRL_DIG_SIL_INTERPOL 0x8000 + +#define SAA7706H_REG_EVALUATION0x1ff0 +#define SAA7706H_EVAL_DISABLE_CHARGE_PUMP 0x01 +#define SAA7706H_EVAL_DCS_CLOCK0x02 +#define SAA7706H_EVAL_GNDRC1_ENABLE0x04 +#define SAA7706H_EVAL_GNDRC2_ENABLE0x08 + +#define SAA7706H_REG_CL_GEN1 0x1ff3 +#define SAA7706H_CL_GEN1_MIN_LOOPGAIN_MASK 0x0f +#define SAA7706H_CL_GEN1_LOOPGAIN_MASK 0xf0 +#define SAA7706H_CL_GEN1_COARSE_RATION 0x00 + +#define SAA7706H_REG_CL_GEN2 0x1ff4 +#define SAA7706H_CL_GEN2_WSEDGE_FALLING0x01 +#define SAA7706H_CL_GEN2_STOP_VCO 0x02 +#define SAA7706H_CL_GEN2_FRERUN0x04 +#define SAA7706H_CL_GEN2_ADAPTIVE 0x08 +#define SAA7706H_CL_GEN2_FINE_RATIO_MASK 0x00 + +#define SAA7706H_REG_CL_GEN4 0x1ff6 +#define SAA7706H_CL_GEN4_BYPASS_PLL1 0x001000 +#define SAA7706H_CL_GEN4_PLL1_DIV_MASK 0x03e000 +#define SAA7706H_CL_GEN4_DSP1_TURBO0x04 + +#define SAA7706H_REG_SEL 0x1ff7 +#define SAA7706H_SEL_DSP2_SRCA_MASK0x07 +#define SAA7706H_SEL_DSP2_FMTA_MASK0x31 +#define SAA7706H_SEL_DSP2_SRCB_MASK0x0001c0 +#define SAA7706H_SEL_DSP2_FMTB_MASK0x000e00 +#define SAA7706H_SEL_DSP1_SRC_MASK 0x003000 +#define SAA7706H_SEL_DSP1_FMT_MASK 0x01c003 +#define SAA7706H_SEL_SPDIF20x02 +#define SAA7706H_SEL_HOST_IO_FMT_MASK 0x1c +#define SAA7706H_SEL_EN_HOST_IO0x20 + +#define SAA7706H_REG_IAC 0x1ff8 +#define SAA7706H_REG_CLK_SET 0x1ff9 +#define SAA7706H_REG_CLK_COEFF 0x1ffa +#define SAA7706H_REG_INPUT_SENS0x1ffb +#define SAA7706H_INPUT_SENS_RDS_VOL_MASK 0x0003f +#define SAA7706H_INPUT_SENS_FM_VOL_MASK0x00fc0 +#define SAA7706H_INPUT_SENS_FM_MPX 0x01000 +#define SAA7706H_INPUT_SENS_OFF_FILTER_A_EN0x02000 +#define SAA7706H_INPUT_SENS_OFF_FILTER_B_EN0x04000 +#define SAA7706H_REG_PHONE_NAV_AUDIO 0x1ffc +#define SAA7706H_REG_IO_CONF_DSP2 0x1ffd +#define SAA7706H_REG_STATUS_DSP2 0x1ffe +#define SAA7706H_REG_PC_DSP2 0x1fff + +#define SAA7706H_DSP1_MOD0
[PATCH 3/3] radio: Add SAA7706H to Kconfig and Makefile
This patch adds the SAA7706H to Kconfig and Makefile, it points out the source code added in the previous patch. Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com --- diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 3f40f37..1716e52 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -417,6 +417,18 @@ config RADIO_TEA5764_XTAL Say Y here if TEA5764 have a 32768 Hz crystal in circuit, say N here if TEA5764 reference frequency is connected in FREQIN. +config RADIO_SAA7706H + tristate SAA7706H Car Radio DSP + depends on I2C VIDEO_V4L2 + ---help--- + Say Y here if you want to use the SAA7706H Car radio Digital + Signal Processor, found for instance on the Russellville development + board. On the russellville the device is connected to internal + timberdale I2C bus. + + To compile this driver as a module, choose M here: the + module will be called SAA7706H. + config RADIO_TEF6862 tristate TEF6862 Car Radio Enhanced Selectivity Tuner depends on I2C VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 01922ad..f681dbf 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o +obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o obj-$(CONFIG_RADIO_TEF6862) += tef6862.o EXTRA_CFLAGS += -Isound -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] radio: Add support for SAA7706H Car Radio DSP
These sets of patches added support for the SAA7706H Car Radio DSP. Patch 1: Add The saa7706h to the v4l2-chip-ident.h Patch 2: Add the actual source code Patch 3: Add the saa7706h to the Kconfig and Makefile --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/4] adv7180 updates
To follow is a series of patches against the adv7180 in the linux-media tree. 1. support for getting input status. 2. support for setting video standard 3. support for interrupt driven update of the video standard 4. usage of the __devinit and __devexit macros --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] adv7180: Support for getting input status
This patch adds support to the ADV7180 driver to check the input status. Since the status is held in the same register as the input standard a small restructuring of the code is done to reuse the code for reading the register Signed-off-by: Richard Röjfors richard.rojf...@mocean-labs.com --- diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c index 1b3cbd0..f3fce39 100644 --- a/drivers/media/video/adv7180.c +++ b/drivers/media/video/adv7180.c @@ -30,14 +30,31 @@ #define DRIVER_NAME adv7180 -#define ADV7180_INPUT_CONTROL_REG 0x00 -#define ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_INPUT_CONTROL_REG 0x00 +#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10 +#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM0x20 +#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_M_SECAM0x30 +#define ADV7180_INPUT_CONTROL_NTSC_J 0x40 +#define ADV7180_INPUT_CONTROL_NTSC_M 0x50 +#define ADV7180_INPUT_CONTROL_PAL600x60 +#define ADV7180_INPUT_CONTROL_NTSC_443 0x70 +#define ADV7180_INPUT_CONTROL_PAL_BG 0x80 +#define ADV7180_INPUT_CONTROL_PAL_N0x90 +#define ADV7180_INPUT_CONTROL_PAL_M0xa0 +#define ADV7180_INPUT_CONTROL_PAL_M_PED0xb0 +#define ADV7180_INPUT_CONTROL_PAL_COMB_N 0xc0 +#define ADV7180_INPUT_CONTROL_PAL_COMB_N_PED 0xd0 +#define ADV7180_INPUT_CONTROL_PAL_SECAM0xe0 +#define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0 + #define ADV7180_AUTODETECT_ENABLE_REG 0x07 #define ADV7180_AUTODETECT_DEFAULT 0x7f -#define ADV7180_STATUS1_REG 0x10 -#define ADV7180_STATUS1_AUTOD_MASK 0x70 +#define ADV7180_STATUS1_REG0x10 +#define ADV7180_STATUS1_IN_LOCK0x01 +#define ADV7180_STATUS1_AUTOD_MASK 0x70 #define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00 #define ADV7180_STATUS1_AUTOD_NTSC_4_43 0x10 #define ADV7180_STATUS1_AUTOD_PAL_M0x20 @@ -55,13 +72,11 @@ struct adv7180_state { struct v4l2_subdev sd; }; -static v4l2_std_id determine_norm(struct i2c_client *client) +static v4l2_std_id adv7180_std_to_v4l2(u8 status1) { - u8 status1 = i2c_smbus_read_byte_data(client, ADV7180_STATUS1_REG); - switch (status1 ADV7180_STATUS1_AUTOD_MASK) { case ADV7180_STATUS1_AUTOD_NTSM_M_J: - return V4L2_STD_NTSC_M_JP; + return V4L2_STD_NTSC; case ADV7180_STATUS1_AUTOD_NTSC_4_43: return V4L2_STD_NTSC_443; case ADV7180_STATUS1_AUTOD_PAL_M: @@ -81,6 +96,30 @@ static v4l2_std_id determine_norm(struct i2c_client *client) } } +static u32 adv7180_status_to_v4l2(u8 status1) +{ + if (!(status1 ADV7180_STATUS1_IN_LOCK)) + return V4L2_IN_ST_NO_SIGNAL; + + return 0; +} + +static int __adv7180_status(struct i2c_client *client, u32 *status, + v4l2_std_id *std) +{ + int status1 = i2c_smbus_read_byte_data(client, ADV7180_STATUS1_REG); + + if (status1 0) + return status1; + + if (status) + *status = adv7180_status_to_v4l2(status1); + if (std) + *std = adv7180_std_to_v4l2(status1); + + return 0; +} + static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) { return container_of(sd, struct adv7180_state, sd); @@ -88,10 +127,12 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { - struct i2c_client *client = v4l2_get_subdevdata(sd); + return __adv7180_status(v4l2_get_subdevdata(sd), NULL, std); +} - *std = determine_norm(client); - return 0; +static int adv7180_g_input_status(struct v4l2_subdev *sd, u32 *status) +{ + return __adv7180_status(v4l2_get_subdevdata(sd), status, NULL); } static int adv7180_g_chip_ident(struct v4l2_subdev *sd, @@ -104,6 +145,7 @@ static int adv7180_g_chip_ident(struct v4l2_subdev *sd, static const struct v4l2_subdev_video_ops adv7180_video_ops = { .querystd = adv7180_querystd, + .g_input_status = adv7180_g_input_status, }; static const struct v4l2_subdev_core_ops adv7180_core_ops = { @@ -143,7 +185,7 @@ static int adv7180_probe(struct i2c_client *client, /* Initialize adv7180 */ /* enable autodetection */ ret = i2c_smbus_write_byte_data(client, ADV7180_INPUT_CONTROL_REG, - ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM); + ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM); if (ret 0) ret = i2c_smbus_write_byte_data(client, ADV7180_AUTODETECT_ENABLE_REG, -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org
[PATCH 2/4] adv7180: Support for setting input status
Support for settings the input standard of the ADV7180. When the input standard is set there is no use to ask the chip for standard, therefore it is cached in the driver. Signed-off-by: Richard Röjfors richard.rojf...@mocean-labs.com --- diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c index f3fce39..8b199a8 100644 --- a/drivers/media/video/adv7180.c +++ b/drivers/media/video/adv7180.c @@ -69,7 +69,9 @@ struct adv7180_state { - struct v4l2_subdev sd; + struct v4l2_subdev sd; + v4l2_std_id curr_norm; + boolautodetect; }; static v4l2_std_id adv7180_std_to_v4l2(u8 status1) @@ -96,6 +98,29 @@ static v4l2_std_id adv7180_std_to_v4l2(u8 status1) } } +static int v4l2_std_to_adv7180(v4l2_std_id std) +{ + if (std == V4L2_STD_PAL_60) + return ADV7180_INPUT_CONTROL_PAL60; + if (std == V4L2_STD_NTSC_443) + return ADV7180_INPUT_CONTROL_NTSC_443; + if (std == V4L2_STD_PAL_N) + return ADV7180_INPUT_CONTROL_PAL_N; + if (std == V4L2_STD_PAL_M) + return ADV7180_INPUT_CONTROL_PAL_M; + if (std == V4L2_STD_PAL_Nc) + return ADV7180_INPUT_CONTROL_PAL_COMB_N; + + if (std V4L2_STD_PAL) + return ADV7180_INPUT_CONTROL_PAL_BG; + if (std V4L2_STD_NTSC) + return ADV7180_INPUT_CONTROL_NTSC_M; + if (std V4L2_STD_SECAM) + return ADV7180_INPUT_CONTROL_PAL_SECAM; + + return -EINVAL; +} + static u32 adv7180_status_to_v4l2(u8 status1) { if (!(status1 ADV7180_STATUS1_IN_LOCK)) @@ -127,7 +152,15 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { - return __adv7180_status(v4l2_get_subdevdata(sd), NULL, std); + struct adv7180_state *state = to_state(sd); + int err = 0; + + if (!state-autodetect) + *std = state-curr_norm; + else + err = __adv7180_status(v4l2_get_subdevdata(sd), NULL, std); + + return err; } static int adv7180_g_input_status(struct v4l2_subdev *sd, u32 *status) @@ -143,6 +176,39 @@ static int adv7180_g_chip_ident(struct v4l2_subdev *sd, return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7180, 0); } +static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) +{ + struct adv7180_state *state = to_state(sd); + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret; + + /* all standards - autodetect */ + if (std == V4L2_STD_ALL) { + ret = i2c_smbus_write_byte_data(client, + ADV7180_INPUT_CONTROL_REG, + ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM); + if (ret 0) + goto out; + + state-autodetect = true; + } else { + ret = v4l2_std_to_adv7180(std); + if (ret 0) + goto out; + + ret = i2c_smbus_write_byte_data(client, + ADV7180_INPUT_CONTROL_REG, ret); + if (ret 0) + goto out; + + state-curr_norm = std; + state-autodetect = false; + } + ret = 0; +out: + return ret; +} + static const struct v4l2_subdev_video_ops adv7180_video_ops = { .querystd = adv7180_querystd, .g_input_status = adv7180_g_input_status, @@ -150,6 +216,7 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = { static const struct v4l2_subdev_core_ops adv7180_core_ops = { .g_chip_ident = adv7180_g_chip_ident, + .s_std = adv7180_s_std, }; static const struct v4l2_subdev_ops adv7180_ops = { @@ -179,6 +246,7 @@ static int adv7180_probe(struct i2c_client *client, state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) return -ENOMEM; + state-autodetect = true; sd = state-sd; v4l2_i2c_subdev_init(sd, client, adv7180_ops); -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] adv7180: Use __devinit and __devexit macros
This patch defines the probe and remove function as __devinit and __devexit. Signed-off-by: Richard Röjfors richard.rojf...@mocean-labs.com --- diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c index d9e897d..0826f0d 100644 --- a/drivers/media/video/adv7180.c +++ b/drivers/media/video/adv7180.c @@ -302,7 +302,7 @@ static irqreturn_t adv7180_irq(int irq, void *devid) * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '1' */ -static int adv7180_probe(struct i2c_client *client, +static __devinit int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; @@ -404,7 +404,7 @@ err: return ret; } -static int adv7180_remove(struct i2c_client *client) +static __devexit int adv7180_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct adv7180_state *state = to_state(sd); @@ -440,7 +440,7 @@ static struct i2c_driver adv7180_driver = { .name = DRIVER_NAME, }, .probe = adv7180_probe, - .remove = adv7180_remove, + .remove = __devexit_p(adv7180_remove), .id_table = adv7180_id, }; -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] adv7180: Support checking standard via interrupts
If the I2C device provides an interrupt it is registered and the standard is updated via interrupts rather than polling. Since I2C communication is needed, the interrupt handler fires off a work which will check the new standard, and store it in the internal structure. To handle mutual exclusion a mutex is introduced. Signed-off-by: Richard Röjfors richard.rojf...@mocean-labs.com --- diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c index 8b199a8..d9e897d 100644 --- a/drivers/media/video/adv7180.c +++ b/drivers/media/video/adv7180.c @@ -27,6 +27,7 @@ #include linux/videodev2.h #include media/v4l2-device.h #include media/v4l2-chip-ident.h +#include linux/mutex.h #define DRIVER_NAME adv7180 @@ -48,9 +49,14 @@ #define ADV7180_INPUT_CONTROL_PAL_SECAM0xe0 #define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0 -#define ADV7180_AUTODETECT_ENABLE_REG 0x07 -#define ADV7180_AUTODETECT_DEFAULT 0x7f +#define ADV7180_EXTENDED_OUTPUT_CONTROL_REG0x04 +#define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS0xC5 +#define ADV7180_AUTODETECT_ENABLE_REG 0x07 +#define ADV7180_AUTODETECT_DEFAULT 0x7f + +#define ADV7180_ADI_CTRL_REG 0x0e +#define ADV7180_ADI_CTRL_IRQ_SPACE 0x20 #define ADV7180_STATUS1_REG0x10 #define ADV7180_STATUS1_IN_LOCK0x01 @@ -67,9 +73,28 @@ #define ADV7180_IDENT_REG 0x11 #define ADV7180_ID_7180 0x18 +#define ADV7180_ICONF1_ADI 0x40 +#define ADV7180_ICONF1_ACTIVE_LOW 0x01 +#define ADV7180_ICONF1_PSYNC_ONLY 0x10 +#define ADV7180_ICONF1_ACTIVE_TO_CLR 0xC0 + +#define ADV7180_IRQ1_LOCK 0x01 +#define ADV7180_IRQ1_UNLOCK0x02 +#define ADV7180_ISR1_ADI 0x42 +#define ADV7180_ICR1_ADI 0x43 +#define ADV7180_IMR1_ADI 0x44 +#define ADV7180_IMR2_ADI 0x48 +#define ADV7180_IRQ3_AD_CHANGE 0x08 +#define ADV7180_ISR3_ADI 0x4A +#define ADV7180_ICR3_ADI 0x4B +#define ADV7180_IMR3_ADI 0x4C +#define ADV7180_IMR4_ADI 0x50 struct adv7180_state { struct v4l2_subdev sd; + struct work_struct work; + struct mutexmutex; /* mutual excl. when accessing chip */ + int irq; v4l2_std_id curr_norm; boolautodetect; }; @@ -153,19 +178,30 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { struct adv7180_state *state = to_state(sd); - int err = 0; + int err = mutex_lock_interruptible(state-mutex); + if (err) + return err; - if (!state-autodetect) + /* when we are interrupt driven we know the state */ + if (!state-autodetect || state-irq 0) *std = state-curr_norm; else err = __adv7180_status(v4l2_get_subdevdata(sd), NULL, std); + mutex_unlock(state-mutex); return err; } static int adv7180_g_input_status(struct v4l2_subdev *sd, u32 *status) { - return __adv7180_status(v4l2_get_subdevdata(sd), status, NULL); + struct adv7180_state *state = to_state(sd); + int ret = mutex_lock_interruptible(state-mutex); + if (ret) + return ret; + + ret = __adv7180_status(v4l2_get_subdevdata(sd), status, NULL); + mutex_unlock(state-mutex); + return ret; } static int adv7180_g_chip_ident(struct v4l2_subdev *sd, @@ -180,7 +216,9 @@ static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) { struct adv7180_state *state = to_state(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); - int ret; + int ret = mutex_lock_interruptible(state-mutex); + if (ret) + return ret; /* all standards - autodetect */ if (std == V4L2_STD_ALL) { @@ -190,6 +228,7 @@ static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) if (ret 0) goto out; + __adv7180_status(client, NULL, state-curr_norm); state-autodetect = true; } else { ret = v4l2_std_to_adv7180(std); @@ -206,6 +245,7 @@ static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) } ret = 0; out: + mutex_unlock(state-mutex); return ret; } @@ -224,6 +264,39 @@ static const struct v4l2_subdev_ops adv7180_ops = { .video = adv7180_video_ops, }; +static void adv7180_work(struct work_struct *work) +{ + struct adv7180_state *state = container_of(work, struct adv7180_state, + work); + struct i2c_client *client = v4l2_get_subdevdata(state-sd); + u8 isr3; + + mutex_lock(state-mutex); + i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, + ADV7180_ADI_CTRL_IRQ_SPACE
Re: [hg:v4l-dvb] video: initial support for ADV7180
Patch from Richard Röjfors wrote: The patch number 13019 was added via Douglas Schilling Landgraf dougsl...@redhat.com to http://linuxtv.org/hg/v4l-dvb master development tree. Kernel patches in this development tree may be modified to be backward compatible with older kernels. Compatibility modifications will be removed before inclusion into the mainstream Kernel If anyone has any objections, please let us know by sending a message to: Linux Media Mailing List linux-media@vger.kernel.org -- Hi, There is a newer version of the driver that has support for beeing interrupt driver and setting standard, and checking the signal status. I would be very happy if that gets committed instead. Here it is: -- Support for the ADV7180 Video Decoder. Includes support for setting, getting video standard and status. The driver can optionally be interrupt driven, otherwise it polls for standard when required. Signed-off-by: Richard Röjfors richard.rojf...@mocean-labs.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 84b6fc1..ac9f636 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -265,6 +265,15 @@ config VIDEO_SAA6588 comment Video decoders +config VIDEO_ADV7180 + tristate Analog Devices ADV7180 decoder + depends on VIDEO_V4L2 I2C + ---help--- + Support for the Analog Devices ADV7180 video decoder. + + To compile this driver as a module, choose M here: the + module will be called adv7180. + config VIDEO_BT819 tristate BT819A VideoStream decoder depends on VIDEO_V4L2 I2C diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 9f2e321..aac0884 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o +obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_BT819) += bt819.o diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c new file mode 100644 index 000..a2169c1 --- /dev/null +++ b/drivers/media/video/adv7180.c @@ -0,0 +1,466 @@ +/* + * adv7180.c Analog Devices ADV7180 video decoder driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include linux/i2c-id.h +#include media/v4l2-ioctl.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h +#include linux/mutex.h + +#define DRIVER_NAME adv7180 + +#define ADV7180_INPUT_CONTROL_REG 0x00 +#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM_PED 0x10 +#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_J_SECAM0x20 +#define ADV7180_INPUT_CONTROL_AD_PAL_N_NTSC_M_SECAM0x30 +#define ADV7180_INPUT_CONTROL_NTSC_J 0x40 +#define ADV7180_INPUT_CONTROL_NTSC_M 0x50 +#define ADV7180_INPUT_CONTROL_PAL600x60 +#define ADV7180_INPUT_CONTROL_NTSC_443 0x70 +#define ADV7180_INPUT_CONTROL_PAL_BG 0x80 +#define ADV7180_INPUT_CONTROL_PAL_N0x90 +#define ADV7180_INPUT_CONTROL_PAL_M0xa0 +#define ADV7180_INPUT_CONTROL_PAL_M_PED0xb0 +#define ADV7180_INPUT_CONTROL_PAL_COMB_N 0xc0 +#define ADV7180_INPUT_CONTROL_PAL_COMB_N_PED 0xd0 +#define ADV7180_INPUT_CONTROL_PAL_SECAM0xe0 +#define ADV7180_INPUT_CONTROL_PAL_SECAM_PED0xf0 + +#define ADV7180_EXTENDED_OUTPUT_CONTROL_REG0x04 +#define ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS0xC5 + +#define ADV7180_AUTODETECT_ENABLE_REG 0x07 +#define ADV7180_AUTODETECT_DEFAULT 0x7f + +#define ADV7180_ADI_CTRL_REG 0x0e +#define ADV7180_ADI_CTRL_IRQ_SPACE 0x20 + +#define ADV7180_STATUS1_REG0x10 +#define ADV7180_STATUS1_IN_LOCK
[patch v2 0/1] video: initial support for ADV7180
This is a an updated version of my previous patch. Hans: I have updated the patch according to you feedback (almost). Thanks for the feedback btw. * I left the state struct even though it only contains the subdev, it's for the future when more functions are added in. * I left the function for checking the norm, also for the future it's for instance possible to get interrupts when the norm is changed, a schedule work or equal could then use this function too. And yes, Mocean laboratories is the author while it's copyrighted to Intel. --Richard -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch v2 1/1] video: initial support for ADV7180
This is an initial driver for Analog Devices ADV7180 Video Decoder. So far it only supports setting the chip in autodetect mode and query the detected standard. Signed-off-by: Richard Röjfors richard.rojfors@mocean-labs.com --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 84b6fc1..ac9f636 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -265,6 +265,15 @@ config VIDEO_SAA6588 comment Video decoders +config VIDEO_ADV7180 + tristate Analog Devices ADV7180 decoder + depends on VIDEO_V4L2 I2C + ---help--- + Support for the Analog Devices ADV7180 video decoder. + + To compile this driver as a module, choose M here: the + module will be called adv7180. + config VIDEO_BT819 tristate BT819A VideoStream decoder depends on VIDEO_V4L2 I2C diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 9f2e321..aac0884 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o +obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_BT819) += bt819.o diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c new file mode 100644 index 000..6607321 --- /dev/null +++ b/drivers/media/video/adv7180.c @@ -0,0 +1,202 @@ +/* + * adv7180.c Analog Devices ADV7180 video decoder driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include linux/i2c-id.h +#include media/v4l2-ioctl.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h + +#define DRIVER_NAME adv7180 + +#define ADV7180_INPUT_CONTROL_REG 0x00 +#define ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_AUTODETECT_ENABLE_REG 0x07 +#define ADV7180_AUTODETECT_DEFAULT 0x7f + + +#define ADV7180_STATUS1_REG 0x10 +#define ADV7180_STATUS1_AUTOD_MASK 0x70 +#define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00 +#define ADV7180_STATUS1_AUTOD_NTSC_4_43 0x10 +#define ADV7180_STATUS1_AUTOD_PAL_M0x20 +#define ADV7180_STATUS1_AUTOD_PAL_60 0x30 +#define ADV7180_STATUS1_AUTOD_PAL_B_G 0x40 +#define ADV7180_STATUS1_AUTOD_SECAM0x50 +#define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60 +#define ADV7180_STATUS1_AUTOD_SECAM_5250x70 + +#define ADV7180_IDENT_REG 0x11 +#define ADV7180_ID_7180 0x18 + + +struct adv7180_state { + struct v4l2_subdev sd; +}; + +static v4l2_std_id determine_norm(struct i2c_client *client) +{ + u8 status1 = i2c_smbus_read_byte_data(client, ADV7180_STATUS1_REG); + + switch (status1 ADV7180_STATUS1_AUTOD_MASK) { + case ADV7180_STATUS1_AUTOD_NTSM_M_J: + return V4L2_STD_NTSC_M_JP; + case ADV7180_STATUS1_AUTOD_NTSC_4_43: + return V4L2_STD_NTSC_443; + case ADV7180_STATUS1_AUTOD_PAL_M: + return V4L2_STD_PAL_M; + case ADV7180_STATUS1_AUTOD_PAL_60: + return V4L2_STD_PAL_60; + case ADV7180_STATUS1_AUTOD_PAL_B_G: + return V4L2_STD_PAL; + case ADV7180_STATUS1_AUTOD_SECAM: + return V4L2_STD_SECAM; + case ADV7180_STATUS1_AUTOD_PAL_COMB: + return V4L2_STD_PAL_Nc | V4L2_STD_PAL_N; + case ADV7180_STATUS1_AUTOD_SECAM_525: + return V4L2_STD_SECAM; + default: + return V4L2_STD_UNKNOWN; + } +} + +static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) +{ + return container_of(sd, struct adv7180_state, sd); +} + +static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + *(v4l2_std_id *)std = determine_norm(client); + return 0; +} + +static int adv7180_g_chip_ident(struct v4l2_subdev *sd, + struct v4l2_dbg_chip_ident *chip) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7180, 0
Re: [patch 1/9] video: initial support for ADV7180
Hi, Hans Verkuil wrote: On Friday 07 August 2009 01:01:12 a...@linux-foundation.org wrote: From: Richard Röjfors richard.rojfors@mocean-labs.com This is an initial driver for Analog Devices ADV7180 Video Decoder. So far it only supports query standard. Hi Richard, Which bridge or platform driver uses this i2c driver? I'm working on drivers for the intel in-vehicle infotainment development board: http://edc.intel.com/Applications/In-Vehicle-Infotainment/Low-Power/ And what is the point of merging such a limited driver? All of the drivers goes into moblin IVI, and the goal is to commit all the drivers to the kernel. I agree, this is an initial limited driver, but functionality can/will be added incrementally when needed. There is a video driver, which will be committed later which uses this subdev. I will update the driver according to you comments, and post it in a couple of days, thanks --Richard More review comments below. Signed-off-by: Richard Röjfors richard.rojfors@mocean-labs.com Cc: Mauro Carvalho Chehab mche...@infradead.org Signed-off-by: Andrew Morton a...@linux-foundation.org --- drivers/media/video/Kconfig |9 + drivers/media/video/Makefile|1 drivers/media/video/adv7180.c | 221 ++ include/media/v4l2-chip-ident.h |3 4 files changed, 234 insertions(+) diff -puN drivers/media/video/Kconfig~video-initial-support-for-adv7180 drivers/media/video/Kconfig --- a/drivers/media/video/Kconfig~video-initial-support-for-adv7180 +++ a/drivers/media/video/Kconfig @@ -265,6 +265,15 @@ config VIDEO_SAA6588 comment Video decoders +config VIDEO_ADV7180 + tristate Analog Devices ADV7180 decoder + depends on VIDEO_V4L2 I2C + ---help--- + Support for the Analog Devices ADV7180 video decoder. + + To compile this driver as a module, choose M here: the + module will be called adv7180. + config VIDEO_BT819 tristate BT819A VideoStream decoder depends on VIDEO_V4L2 I2C diff -puN drivers/media/video/Makefile~video-initial-support-for-adv7180 drivers/media/video/Makefile --- a/drivers/media/video/Makefile~video-initial-support-for-adv7180 +++ a/drivers/media/video/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o +obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_BT819) += bt819.o diff -puN /dev/null drivers/media/video/adv7180.c --- /dev/null +++ a/drivers/media/video/adv7180.c @@ -0,0 +1,221 @@ +/* + * adv7180.c Analog Devices ADV7180 video decoder driver + * Copyright (c) 2009 Intel Corporation The author is set to Mocean Laboratories, but the copyright is Intel. Is that correct? (Just checking) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include linux/i2c-id.h +#include media/v4l2-ioctl.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h +#include media/v4l2-i2c-drv.h This is a compatibility header to allow this driver to be compiled under kernels 2.6.26. If you do not need that, then you should make this a regular i2c driver (see for example drivers/media/video/adv7343.c). + + +#define ADV7180_INPUT_CONTROL_REG 0x00 +#define ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_AUTODETECT_ENABLE_REG 0x07 +#define ADV7180_AUTODETECT_DEFAULT 0x7f + + +#define ADV7180_STATUS1_REG 0x10 +#define ADV7180_STATUS1_AUTOD_MASK 0x70 +#define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00 +#define ADV7180_STATUS1_AUTOD_NTSC_4_43 0x10 +#define ADV7180_STATUS1_AUTOD_PAL_M0x20 +#define ADV7180_STATUS1_AUTOD_PAL_60 0x30 +#define ADV7180_STATUS1_AUTOD_PAL_B_G 0x40 +#define ADV7180_STATUS1_AUTOD_SECAM0x50 +#define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60 +#define ADV7180_STATUS1_AUTOD_SECAM_5250x70 + +#define ADV7180_IDENT_REG 0x11 +#define ADV7180_ID_7180 0x18 + + +static unsigned short normal_i2c[] = { 0x42 1, I2C_CLIENT_END }; + +I2C_CLIENT_INSMOD; The three lines above are not needed for kernels = 2.6.26
[RESEND][PATCH] video: Initial support for ADV7180
This is an initial driver for Analog Devices ADV7180 Video Decoder. So far it only supports query standard. Signed-off-by: Richard Röjfors richard.rojfors@mocean-labs.com --- Index: linux-2.6.30-rc7/drivers/media/video/adv7180.c === --- linux-2.6.30-rc7/drivers/media/video/adv7180.c (revision 0) +++ linux-2.6.30-rc7/drivers/media/video/adv7180.c (revision 867) @@ -0,0 +1,221 @@ +/* + * adv7180.c Analog Devices ADV7180 video decoder driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include linux/module.h +#include linux/init.h +#include linux/errno.h +#include linux/kernel.h +#include linux/interrupt.h +#include linux/i2c.h +#include linux/i2c-id.h +#include media/v4l2-ioctl.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-chip-ident.h +#include media/v4l2-i2c-drv.h + + +#define ADV7180_INPUT_CONTROL_REG 0x00 +#define ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM 0x00 +#define ADV7180_AUTODETECT_ENABLE_REG 0x07 +#define ADV7180_AUTODETECT_DEFAULT 0x7f + + +#define ADV7180_STATUS1_REG 0x10 +#define ADV7180_STATUS1_AUTOD_MASK 0x70 +#define ADV7180_STATUS1_AUTOD_NTSM_M_J 0x00 +#define ADV7180_STATUS1_AUTOD_NTSC_4_43 0x10 +#define ADV7180_STATUS1_AUTOD_PAL_M0x20 +#define ADV7180_STATUS1_AUTOD_PAL_60 0x30 +#define ADV7180_STATUS1_AUTOD_PAL_B_G 0x40 +#define ADV7180_STATUS1_AUTOD_SECAM0x50 +#define ADV7180_STATUS1_AUTOD_PAL_COMB 0x60 +#define ADV7180_STATUS1_AUTOD_SECAM_5250x70 + +#define ADV7180_IDENT_REG 0x11 +#define ADV7180_ID_7180 0x18 + + +static unsigned short normal_i2c[] = { 0x42 1, I2C_CLIENT_END }; + +I2C_CLIENT_INSMOD; + +struct adv7180_state { + struct v4l2_subdev sd; +}; + +static v4l2_std_id determine_norm(struct i2c_client *client) +{ + u8 status1 = i2c_smbus_read_byte_data(client, ADV7180_STATUS1_REG); + + switch (status1 ADV7180_STATUS1_AUTOD_MASK) { + case ADV7180_STATUS1_AUTOD_NTSM_M_J: + return V4L2_STD_NTSC_M_JP; + case ADV7180_STATUS1_AUTOD_NTSC_4_43: + return V4L2_STD_NTSC_443; + case ADV7180_STATUS1_AUTOD_PAL_M: + return V4L2_STD_PAL_M; + case ADV7180_STATUS1_AUTOD_PAL_60: + return V4L2_STD_PAL_60; + case ADV7180_STATUS1_AUTOD_PAL_B_G: + return V4L2_STD_PAL; + case ADV7180_STATUS1_AUTOD_SECAM: + return V4L2_STD_SECAM; + case ADV7180_STATUS1_AUTOD_PAL_COMB: + return V4L2_STD_PAL_Nc | V4L2_STD_PAL_N; + case ADV7180_STATUS1_AUTOD_SECAM_525: + return V4L2_STD_SECAM; + default: + return V4L2_STD_UNKNOWN; + } +} + +static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) +{ + return container_of(sd, struct adv7180_state, sd); +} + +static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + *(v4l2_std_id *)std = determine_norm(client); + return 0; +} + +static int adv7180_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) +{ + return -EINVAL; +} + +static int adv7180_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) +{ + return -EINVAL; +} + +static int adv7180_g_chip_ident(struct v4l2_subdev *sd, + struct v4l2_dbg_chip_ident *chip) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7180, 0); +} + +static int adv7180_log_status(struct v4l2_subdev *sd) +{ + v4l2_info(sd, Normal operation\n); + return 0; +} + +static irqreturn_t adv7180_irq(int irq, void *devid) +{ + return IRQ_NONE; +} + +static const struct v4l2_subdev_video_ops adv7180_video_ops = { + .querystd = adv7180_querystd, +}; + +static const struct v4l2_subdev_core_ops adv7180_core_ops = { + .log_status = adv7180_log_status, + .g_chip_ident = adv7180_g_chip_ident, + .g_ctrl = adv7180_g_ctrl, + .s_ctrl = adv7180_s_ctrl, +}; + +static const struct v4l2_subdev_ops adv7180_ops = { + .core = adv7180_core_ops, + .video = adv7180_video_ops, +}; + +/* + * Generic i2c probe + * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '1' + */ + +static int
[PATCH 5/9] V4L2: Added Timberdale Logiwin driver
V4L2 video capture driver for the logiwin IP on the Timberdale FPGA. The driver uses the Timberdale DMA engine Signed-off-by: Richard Röjfors richard.rojfors@mocean-labs.com --- Index: linux-2.6.30-rc7/drivers/media/video/timblogiw.c === --- linux-2.6.30-rc7/drivers/media/video/timblogiw.c(revision 0) +++ linux-2.6.30-rc7/drivers/media/video/timblogiw.c(revision 867) @@ -0,0 +1,949 @@ +/* + * timblogiw.c timberdale FPGA LogiWin Video In driver + * Copyright (c) 2009 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supports: + * Timberdale FPGA LogiWin Video In + */ + +#include linux/list.h +#include linux/version.h +#include linux/module.h +#include linux/pci.h +#include linux/dma-mapping.h +#include media/v4l2-common.h +#include media/v4l2-ioctl.h +#include media/v4l2-device.h +#include linux/platform_device.h +#include linux/interrupt.h +#include timblogiw.h +#include linux/mfd/timbdma.h +#include linux/i2c.h +#include media/timb_video.h + +#define TIMBLOGIW_CTRL 0x40 + +#define TIMBLOGIW_H_SCALE 0x20 +#define TIMBLOGIW_V_SCALE 0x28 + +#define TIMBLOGIW_X_CROP 0x58 +#define TIMBLOGIW_Y_CROP 0x60 + +#define TIMBLOGIW_W_CROP 0x00 +#define TIMBLOGIW_H_CROP 0x08 + +#define TIMBLOGIW_VERSION_CODE 0x02 + +#define TIMBLOGIW_BUF 0x04 +#define TIMBLOGIW_TBI 0x2c +#define TIMBLOGIW_BPL 0x30 + +#define dbg(...) + +#define DMA_BUFFER_SIZE (720 * 576 * 2) + +const struct timblogiw_tvnorm timblogiw_tvnorms[] = { + { + .std= V4L2_STD_PAL, + .name = PAL, + .width = 720, + .height = 576 + }, + { + .std= V4L2_STD_NTSC_M, + .name = NTSC, + .width = 720, + .height = 480 + } +}; + +static int timblogiw_bytes_per_line(const struct timblogiw_tvnorm *norm) +{ + return norm-width * 2; +} + + +static int timblogiw_frame_size(const struct timblogiw_tvnorm *norm) +{ + return norm-height * timblogiw_bytes_per_line(norm); +} + +static const struct timblogiw_tvnorm *timblogiw_get_norm(const v4l2_std_id std) +{ + int i; + for (i = 0; i ARRAY_SIZE(timblogiw_tvnorms); i++) + if (timblogiw_tvnorms[i].std == std) + return timblogiw_tvnorms + i; + + /* default to first element */ + return timblogiw_tvnorms; +} + +static void timblogiw_handleframe(unsigned long arg) +{ + struct timblogiw_frame *f; + struct timblogiw *lw = (struct timblogiw *)arg; + + spin_lock_bh(lw-queue_lock); + if (lw-dma.filled !list_empty(lw-inqueue)) { + /* put the entry in the outqueue */ + f = list_entry(lw-inqueue.next, struct timblogiw_frame, frame); + + /* copy data from the DMA buffer */ + memcpy(f-bufmem, lw-dma.filled-buf, f-buf.length); + /* buffer consumed */ + lw-dma.filled = NULL; + + do_gettimeofday(f-buf.timestamp); + f-buf.sequence = ++lw-frame_count; + f-buf.field = V4L2_FIELD_NONE; + f-state = F_DONE; + f-buf.bytesused = f-buf.length; + list_move_tail(f-frame, lw-outqueue); + /* wake up any waiter */ + wake_up(lw-wait_frame); + } else { + /* No user buffer available, consume buffer anyway +* who wants an old video frame? +*/ + lw-dma.filled = NULL; + } + spin_unlock_bh(lw-queue_lock); +} + +static int timblogiw_isr(u32 flag, void *pdev) +{ + struct timblogiw *lw = (struct timblogiw *)pdev; + + if (!lw-dma.filled (flag DMA_IRQ_VIDEO_RX)) { + /* Got a frame, store it, and flip to next DMA buffer */ + lw-dma.filled = lw-dma.transfer + lw-dma.curr; + lw-dma.curr = !lw-dma.curr; + } + + if (lw-stream == STREAM_ON) + timb_start_dma(DMA_IRQ_VIDEO_RX, + lw-dma.transfer[lw-dma.curr].handle, + timblogiw_frame_size(lw-cur_norm), + timblogiw_bytes_per_line(lw-cur_norm
[PATCH 6/9] V4L2: Added Timberdale Logiwin driver in Kconfig and Makefile
Updates of Kconfig and Makefile for the Timberdale logiwin driver Signed-off-by: Richard Röjfors richard.rojfors@mocean-labs.com --- Index: linux-2.6.30-rc7/drivers/media/video/Kconfig === --- linux-2.6.30-rc7/drivers/media/video/Kconfig(revision 861) +++ linux-2.6.30-rc7/drivers/media/video/Kconfig(working copy) @@ -786,6 +786,13 @@ ---help--- This is a v4l2 driver for the TI OMAP2 camera capture interface +config VIDEO_TIMBERDALE + tristate Support for timberdale Video In/LogiWIN + depends on VIDEO_V4L2 MFD_TIMBERDALE_DMA + select VIDEO_ADV7180 + ---help--- + Add support for the Video In peripherial of the timberdale FPGA. + # # USB Multimedia device configuration # Index: linux-2.6.30-rc7/drivers/media/video/Makefile === --- linux-2.6.30-rc7/drivers/media/video/Makefile (revision 861) +++ linux-2.6.30-rc7/drivers/media/video/Makefile (working copy) @@ -150,6 +150,8 @@ obj-$(CONFIG_VIDEO_AU0828) += au0828/ +obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o + obj-$(CONFIG_USB_VIDEO_CLASS) += uvc/ EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html