Re: [RFC PATCH 1/3] adv7842: add new video decoder driver.
On 08/16/2013 12:10 PM, Scott Jiang wrote: + +static int adv7842_g_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7842_state *state = to_state(sd); + + fmt-width = state-timings.bt.width; + fmt-height = state-timings.bt.height; + fmt-code = V4L2_MBUS_FMT_FIXED; + fmt-field = V4L2_FIELD_NONE; + + if (state-mode == ADV7842_MODE_SDP) { + /* SPD block */ + if (!(sdp_read(sd, 0x5A) 0x01)) + return -EINVAL; + fmt-width = 720; + /* valid signal */ + if (state-norm V4L2_STD_525_60) + fmt-height = 480; + else + fmt-height = 576; + fmt-colorspace = V4L2_COLORSPACE_SMPTE170M; + return 0; + } + I believe someone use SDP mode to capture 480i instead of 480p. I think we can add a table to map adv7842 output setting and v4l format. The driver as it stands only supports progressive output from the chip, because that is all we support in our products (interlaced video conferencing? Nah, not a good idea...). I don't think I can easily test it (if at all!), so I leave this as an exercise for the reader. +static int adv7842_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) +{ + struct adv7842_state *state = to_state(sd); + + v4l2_dbg(1, debug, sd, %s:\n, __func__); + + if (state-mode != ADV7842_MODE_SDP) + return -ENODATA; + + if (norm V4L2_STD_ALL) { + state-norm = norm; + return 0; + } + return -EINVAL; +} Why is there no hardware operation? if (std == V4L2_STD_NTSC_443) val = 0x20; else if (std == V4L2_STD_PAL_60) val = 0x10; else if (std == V4L2_STD_PAL_Nc) val = 0x08; else if (std == V4L2_STD_PAL_M) val = 0x04; else if (std V4L2_STD_NTSC) val = 0x02; else if (std V4L2_STD_PAL) val = 0x01; else if (std V4L2_STD_SECAM) val = 0x40; else return -EINVAL; /* force the digital core into a specific video standard */ sdp_write(sd, 0x0, val); /* wait 100ms, otherwise color will be lost */ msleep(100); state-std = std; return 0; I checked with Martin Bugge who wrote this and the reason is that apparently forcing the core to a specific standard will break the querystd functionality. That said, this can definitely be improved by only forcing the standard when you start streaming and reverting to the autodetect mode when streaming stops. QUERYSTD can return -EBUSY when streaming is on. I would prefer to do this in a separate patch later, though, as this will take some time to implement and especially test. Regards, Hans -- 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: [RFC PATCH 1/3] adv7842: add new video decoder driver.
+ +static int adv7842_g_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7842_state *state = to_state(sd); + + fmt-width = state-timings.bt.width; + fmt-height = state-timings.bt.height; + fmt-code = V4L2_MBUS_FMT_FIXED; + fmt-field = V4L2_FIELD_NONE; + + if (state-mode == ADV7842_MODE_SDP) { + /* SPD block */ + if (!(sdp_read(sd, 0x5A) 0x01)) + return -EINVAL; + fmt-width = 720; + /* valid signal */ + if (state-norm V4L2_STD_525_60) + fmt-height = 480; + else + fmt-height = 576; + fmt-colorspace = V4L2_COLORSPACE_SMPTE170M; + return 0; + } + I believe someone use SDP mode to capture 480i instead of 480p. I think we can add a table to map adv7842 output setting and v4l format. +static int adv7842_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) +{ + struct adv7842_state *state = to_state(sd); + + v4l2_dbg(1, debug, sd, %s:\n, __func__); + + if (state-mode != ADV7842_MODE_SDP) + return -ENODATA; + + if (norm V4L2_STD_ALL) { + state-norm = norm; + return 0; + } + return -EINVAL; +} Why is there no hardware operation? if (std == V4L2_STD_NTSC_443) val = 0x20; else if (std == V4L2_STD_PAL_60) val = 0x10; else if (std == V4L2_STD_PAL_Nc) val = 0x08; else if (std == V4L2_STD_PAL_M) val = 0x04; else if (std V4L2_STD_NTSC) val = 0x02; else if (std V4L2_STD_PAL) val = 0x01; else if (std V4L2_STD_SECAM) val = 0x40; else return -EINVAL; /* force the digital core into a specific video standard */ sdp_write(sd, 0x0, val); /* wait 100ms, otherwise color will be lost */ msleep(100); state-std = std; return 0; -- 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: [RFC PATCH 1/3] adv7842: add new video decoder driver.
On 08/14/2013 05:10 AM, Prabhakar Lad wrote: Hi Hans, Thanks for the patch. Few nits below. On Mon, Aug 12, 2013 at 6:43 PM, Hans Verkuil hverk...@xs4all.nl wrote: From: Hans Verkuil hans.verk...@cisco.com Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/i2c/Kconfig | 12 + drivers/media/i2c/Makefile |1 + drivers/media/i2c/adv7842.c | 3022 +++ include/media/adv7842.h | 226 4 files changed, 3261 insertions(+) create mode 100644 drivers/media/i2c/adv7842.c create mode 100644 include/media/adv7842.h diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index b2cd8ca..847b711 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -206,6 +206,18 @@ config VIDEO_ADV7604 To compile this driver as a module, choose M here: the module will be called adv7604. +config VIDEO_ADV7842 + tristate Analog Devices ADV7842 decoder + depends on VIDEO_V4L2 I2C VIDEO_V4L2_SUBDEV_API + ---help--- + Support for the Analog Devices ADV7842 video decoder. + + This is a Analog Devices Component/Graphics/SD Digitizer + with 2:1 Multiplexed HDMI Receiver. + + To compile this driver as a module, choose M here: the + module will be called adv7842. + config VIDEO_BT819 tristate BT819A VideoStream decoder depends on VIDEO_V4L2 I2C diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index dc20653..b4cf972 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o obj-$(CONFIG_VIDEO_ADV7393) += adv7393.o obj-$(CONFIG_VIDEO_ADV7604) += adv7604.o +obj-$(CONFIG_VIDEO_ADV7842) += adv7842.o obj-$(CONFIG_VIDEO_AD9389B) += ad9389b.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_VS6624) += vs6624.o diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c new file mode 100644 index 000..84c9a83 --- /dev/null +++ b/drivers/media/i2c/adv7842.c @@ -0,0 +1,3022 @@ +/* + * adv7842 - Analog Devices ADV7842 video decoder driver + * + * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +/* + * References (c = chapter, p = page): + * REF_01 - Analog devices, ADV7842, Register Settings Recommendations, + * Revision 2.5, June 2010 + * REF_02 - Analog devices, Register map documentation, Documentation of + * the register maps, Software manual, Rev. F, June 2010 + */ + + +#include linux/kernel.h +#include linux/module.h +#include linux/slab.h +#include linux/i2c.h +#include linux/delay.h +#include linux/videodev2.h +#include linux/workqueue.h +#include linux/v4l2-dv-timings.h +#include media/v4l2-device.h +#include media/v4l2-ctrls.h +#include media/adv7842.h + +static int debug; +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, debug level (0-2)); + +MODULE_DESCRIPTION(Analog Devices ADV7842 video decoder driver); +MODULE_AUTHOR(Hans Verkuil hans.verk...@cisco.com); +MODULE_AUTHOR(Martin Bugge marbu...@cisco.com); +MODULE_LICENSE(GPL); + +/* ADV7842 system clock frequency */ +#define ADV7842_fsc (28636360) + +/* +** +* +* Arrays with configuration parameters for the ADV7842 +* +** +*/ + +struct adv7842_state { + struct v4l2_subdev sd; + struct media_pad pad; + struct v4l2_ctrl_handler hdl; + enum adv7842_mode mode; + struct v4l2_dv_timings timings; + enum adv7842_vid_std_select vid_std_select; + v4l2_std_id norm; + struct { + u8 edid[256]; + u32 present; + } hdmi_edid; + struct { + u8 edid[256]; + u32 present; + } vga_edid; + struct v4l2_fract aspect_ratio; + u32 rgb_quantization_range; + bool is_cea_format; + struct workqueue_struct *work_queues; + struct delayed_work