Add tw9910 driver
PATCH v3 1/1 Add tw9910 driver
This patch adds tw9910 driver that use soc_camera framework. It was tested on SH Migo-r board and mplayer.
---
v2 -> v3
o add tw9910_set_std function
o add tw9910_enum_input function
drivers/media/video/Kconfig | 6 + drivers/media/video/Makefile | 1 + drivers/media/video/tw9910.c | 955 +++++++++++++++++++++++++++++++++++++++ include/media/tw9910.h | 39 ++ include/media/v4l2-chip-ident.h | 3 + 5 files changed, 1004 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/tw9910.c create mode 100644 include/media/tw9910.h
drivers/media/video/Kconfig +6 -0
@@ -744,6 +744,12 @@ config MT9V022_PCA9536_SWITCH Select this if your MT9V022 camera uses a PCA9536 I2C GPIO extender to switch between 8 and 10 bit datawidth modes +config SOC_CAMERA_TW9910 + tristate "tw9910 support" + depends on SOC_CAMERA && I2C + help + This is a tw9910 video driver + config SOC_CAMERA_PLATFORM tristate "platform camera support" depends on SOC_CAMERA
drivers/media/video/Makefile +1 -0
@@ -135,6 +135,7 @@ obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o +obj-$(CONFIG_SOC_CAMERA_TW9910) += tw9910.o obj-$(CONFIG_VIDEO_AU0828) += au0828/
drivers/media/video/tw9910.c new file +955 -0
955 lines not on this page · raw message
include/media/tw9910.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* tw9910 Driver header +* +* Copyright (C) 2008 Renesas Solutions Corp. +* Kuninori Morimoto <[email protected]> +* +* Based on ov772x.h +* +* Copyright (C) Kuninori Morimoto <[email protected]> +* +* 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. +*/ + +#ifndef __TW9910_H__ +#define __TW9910_H__ + +#include <media/soc_camera.h> + +enum MPOUT_pin { +MPO_VLOSS , +MPO_HLOCK , +MPO_SLOCK , +MPO_VLOCK , +MPO_MONO , +MPO_DET50 , +MPO_FIELD , +MPO_RTCO , +}; + +struct tw9910_video_info { +unsigned long buswidth; +enum MPOUT_pin mpout; +struct soc_camera_link link; +}; + + +#endif /* __TW9910_H__ */
include/media/v4l2-chip-ident.h +3 -0
@@ -84,6 +84,9 @@ enum {/* module wm8775: just ident 8775 */ V4L2_IDENT_WM8775 =8775 , +/* module tw9910: just ident 9910 */ +V4L2_IDENT_TW9910 =9910 , +/* module cs53132a: just ident 53132 */ V4L2_IDENT_CS53l32A = 53132,
Signature · 6 lines
1.5.6.3 -- video4linux-list mailing list Unsubscribe mailto:[email protected]?subject=unsubscribe https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 10 lines · Kuninori Morimoto
This patch adds tw9910 driver that use
soc_cameraframework. It was tested on SH Migo-r board and mplayer.Signed-off-by Kuninori Morimoto <[email protected]>---
v2 -> v3o add
tw9910_set_stdfunction
o addtw9910_enum_inputfunction
Ok, these two are fine now. But
Quoted 8 lines
drivers/media/video/tw9910.c new file +8
-0+static int tw9910_try_fmt (struct soc_camera_device *icd, +struct v4l2_format *f) +{ +struct v4l2_pix_format *pix = &f->fmt.pix; +__u32 wmax = (__u32 )icd->width_max; +__u32 wmin = (__u32 )icd->width_min; +__u32 hmax = (__u32 )icd->height_max; +__u32 hmin = (__u32 )icd->height_min;
drivers/media/video/tw9910.c line 765
Quoted 10 lines
drivers/media/video/tw9910.c new file +10
-0+ + pix->width =min (pix->width, wmax); + pix->width =max (pix->width, wmin); + pix->height =min (pix->height, hmax); + pix->height =max (pix->height, hmin); + + pix->field =V4L2_FIELD_INTERLACED ; + +return 0 ; +}
You forgot to fix this one. Please, look again what O've written to you regarding this function. You may replace the field, if it is V4L2_FIELD_ANY, but if it is something different, you have to return -EINVAL.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Thank you for checking my patch
Quoted 15 lines
Quoted 15 lines
drivers/media/video/tw9910.c new file +15
-0+static int tw9910_try_fmt (struct soc_camera_device *icd, +struct v4l2_format *f) +{ +struct v4l2_pix_format *pix = &f->fmt.pix; +__u32 wmax = (__u32 )icd->width_max; +__u32 wmin = (__u32 )icd->width_min; +__u32 hmax = (__u32 )icd->height_max; +__u32 hmin = (__u32 )icd->height_min; + + pix->width =min (pix->width, wmax); + pix->width =max (pix->width, wmin); + pix->height =min (pix->height, hmax); + pix->height =max (pix->height, hmin); + + pix->field =V4L2_FIELD_INTERLACED ;
Quoted 8 lines
drivers/media/video/tw9910.c line 459
Quoted 3 lines
drivers/media/video/tw9910.c new file +3
-0+ +return 0 ; +}You forgot to fix this one. Please, look again what O've written to you regarding this function. You may replace the field, if it is
V4L2_FIELD_ANY, but if it is something different, you have to return-EINVAL.
Sorry I forget to tell you about this.
I tried it.
but pix->field was V4L2_FIELD_NONE when tw9910_try_fmt was 1st called.
debug code is like this
----------------------------------------------------------
static int tw9910_try_fmt(struct soc_camera_device *icd,
struct v4l2_format *f)
{
struct v4l2_pix_format *pix = &f->fmt.pix;
....
if(pix->field == V4L2_FIELD_NONE)
printk("V4L2_FIELD_NONE\n")
if(pix->field == V4L2_FIELD_ANY)
printk("V4L2_FIELD_ANY\n")
if(pix->field == V4L2_FIELD_NONE)
printk("V4L2_FIELD_INTERLACED\n")...
}
----------------------------------------------------------
answer is
----------------------------------------------------------
...V4L2_FIELD_NONEV4L2_FIELD_ANYV4L2_FIELD_INTERLACEDV4L2_FIELD_ANY
...
----------------------------------------------------------
I just removed field check from soc_camera.c :: soc_camera_fry_fmt_vid_cap It it not enough ?
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 24 lines · On Tue, 16 Dec 2008, [email protected] wrote:
Quoted 15 lines
Quoted 15 lines
drivers/media/video/tw9910.c new file +15
-0+static int tw9910_try_fmt (struct soc_camera_device *icd, +struct v4l2_format *f) +{ +struct v4l2_pix_format *pix = &f->fmt.pix; +__u32 wmax = (__u32 )icd->width_max; +__u32 wmin = (__u32 )icd->width_min; +__u32 hmax = (__u32 )icd->height_max; +__u32 hmin = (__u32 )icd->height_min; + + pix->width =min (pix->width, wmax); + pix->width =max (pix->width, wmin); + pix->height =min (pix->height, hmax); + pix->height =max (pix->height, hmin); + + pix->field =V4L2_FIELD_INTERLACED ;Quoted 8 lines
drivers/media/video/tw9910.c line 459
Quoted 3 lines
drivers/media/video/tw9910.c new file +3
-0+ +return 0 ; +}You forgot to fix this one. Please, look again what O've written to you regarding this function. You may replace the field, if it is
V4L2_FIELD_ANY, but if it is something different, you have to return-EINVAL.
Quoted 3 lines
Sorry I forget to tell you about this.
I tried it.
butpix->fieldwasV4L2_FIELD_NONEwhentw9910_try_fmtwas 1st called.
Yes, that's fine. This depends on your application - whatever you use. And I would expect, if you first return -EINVAL in reply to FIELD_NONE, the application then will try either ANY or INTERLACED, and you will get a chance to select a suitable field.
Quoted 29 lines
debug code is like this
----------------------------------------------------------
static int tw9910_try_fmt(structsoc_camera_device*icd,
structv4l2_format*f){ struct v4l2_pix_format *pix = &f->fmt.pix; .... if(pix->field == V4L2_FIELD_NONE) printk("V4L2_FIELD_NONE\n") if(pix->field == V4L2_FIELD_ANY) printk("V4L2_FIELD_ANY\n") if(pix->field == V4L2_FIELD_NONE) printk("V4L2_FIELD_INTERLACED\n")...
}
----------------------------------------------------------answer is
----------------------------------------------------------
...V4L2_FIELD_NONEV4L2_FIELD_ANYV4L2_FIELD_INTERLACEDV4L2_FIELD_ANY
...
----------------------------------------------------------
Quoted 2 lines
I just removed field check from
soc_camera.c::soc_camera_fry_fmt_vid_capIt it not enough ?
It is, this looks fine. Just try returning -EINVAL on NONE and see if the application manages it.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 8 lines
Quoted 3 lines
Sorry I forget to tell you about this.
I tried it.
butpix->fieldwasV4L2_FIELD_NONEwhentw9910_try_fmtwas 1st called.Yes, that's fine. This depends on your application - whatever you use. And I would expect, if you first return
-EINVALin reply toFIELD_NONE, the application then will try either ANY or INTERLACED, and you will get a chance to select a suitable field.
really ???
Now I'm using mplayer.
but mplayer doesn't try ANY or INTERLACED.
And if try_fmt return -EINVAL, mplayer will just finish.
Is mplayer's option wrong ?
--------------
Quoted 6 lines
VGA="-tv width=640:height=480 -zoom -x 320 -y 240" VIDIX="-vo fbdev:vidix:sh_veu"
OUT="tv://"
NTSC="-tv norm=NTSC"mplayer ${VIDIX} ${VGA} ${NTSC} ${OUT}
--------------
answer of mplayer.
(try_fmt return -EINVAL when field is NONE)
--------------
MPlayer dev-SVN-r27776-4.2-SH4-LINUX_v0701 (C) 2000-2008 MPlayer Team
Playing tv://.
TV file format detected.camera 0-0: SuperH Mobile CEU driver attached to camera 0
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
Selected device: SuperH_Mobile_CEU
Capcamera 0-0: SuperH Mobile CEU driver detached from camera 0
abilites: video capture streaming
supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR; 4 = PAL; 5 = PAL-BG; 6 = PAL-H; 7 = PAL-I; 8 = PAL-DK;
inputs: 0 = Video;
Current input: 0
Current format: NV12
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
--------------
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Mauro, please, see below.
Quoted 38 lines · On Tue, 16 Dec 2008, [email protected] wrote:
Dear Guennadi
Quoted 8 lines
Quoted 3 lines
Sorry I forget to tell you about this.
I tried it.
butpix->fieldwasV4L2_FIELD_NONEwhentw9910_try_fmtwas 1st called.Yes, that's fine. This depends on your application - whatever you use. And I would expect, if you first return
-EINVALin reply toFIELD_NONE, the application then will try either ANY or INTERLACED, and you will get a chance to select a suitable field.really ???
Now I'm using mplayer.
but mplayer doesn't try ANY or INTERLACED.And if
try_fmtreturn-EINVAL, mplayer will just finish.Is mplayer's option wrong ?
--------------
Quoted 6 lines
VGA="-tv width=640:height=480 -zoom -x 320 -y 240" VIDIX="-vo fbdev:vidix:sh_veu"
OUT="tv://"
NTSC="-tv norm=NTSC"mplayer ${VIDIX} ${VGA} ${NTSC} ${OUT}
--------------
answer of mplayer.
(try_fmtreturn-EINVALwhen field is NONE)--------------
MPlayer dev-SVN-r27776-4.2-SH4-LINUX_v0701 (C) 2000-2008 MPlayer TeamPlaying tv://.
TV file format detected.camera 0-0: SuperH Mobile CEU driver attached to camera 0
Quoted 16 lines
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <[email protected]>
comment: first try, more to come ;-)
Selected device:SuperH_Mobile_CEU
Capcamera 0-0: SuperH Mobile CEU driver detached from camera 0
abilites: video capture streaming
supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR; 4 = PAL; 5 = PAL-BG; 6 = PAL-H; 7 = PAL-I; 8 = PAL-DK;
inputs: 0 = Video;
Current input: 0
Current format: NV12
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
--------------
Cannot say for sure, but here is a code snippet from some random mplayer version I have here (some 1.0-rc2):
case TVI_CONTROL_VID_SET_FORMAT:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
priv->format.fmt.pix.pixelformat = fcc_mp2vl(*(int *)arg);
priv->format.fmt.pix.field = V4L2_FIELD_ANY;
priv->mp_format = *(int *)arg;
mp_msg(MSGT_TV, MSGL_V, "%s: set format: %s\n", info.short_name,
pixfmt2name(priv->format.fmt.pix.pixelformat));
if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
info.short_name, strerror(errno));
return TVI_CONTROL_FALSE;
}
/* according to the v4l2 specs VIDIOC_S_FMT should not fail, inflexible drivers
might even always return the default parameters -> update the format here*/
priv->mp_format = fcc_vl2mp(priv->format.fmt.pix.pixelformat);
return TVI_CONTROL_TRUE;so, here it is trying ANY... OTOH, the comment above says the driver shouldn't fail this call, and http://v4l2spec.bytesex.org/spec/r10944.htm
confirms that. Which also means, that vivi.c does it wrongly. Mauro, you are listed as one of the authors of vivi.c, and it looks like calling S_FMT on it with field != ANY && field != INTERLACED will produce -EINVAL, which seems to contradict the API. What is the correct behavious? Is this a bug in vivi.c?
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 3 lines
Quoted 3 lines
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
(snip)
Quoted 10 lines
case TVI_CONTROL_VID_SET_FORMAT:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
priv->format.fmt.pix.pixelformat = fcc_mp2vl(*(int *)arg);
priv->format.fmt.pix.field = V4L2_FIELD_ANY;
priv->mp_format = *(int *)arg;
mp_msg(MSGT_TV, MSGL_V, "%s: set format: %s\n", info.short_name,
pixfmt2name(priv->format.fmt.pix.pixelformat));
if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",mplayer said "ioctl set format failed: Invalid argument". but it is not here.
it is from${MPALYER}/stream/tvi_v4l2.c :: static int init(priv_t *priv)
--------------------------------
/* set some nice defaults */
if (getfmt(priv) < 0) return 0;
priv->format.fmt.pix.width = 640;
priv->format.fmt.pix.height = 480;
if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
info.short_name, strerror(errno));
uninit(priv);
return 0;
}--------------------------------
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 7 lines · On Tue, 16 Dec 2008 11:09:21 +0100 (CET) Guennadi Liakhovetski…
so, here it is trying ANY... OTOH, the comment above says the driver shouldn't fail this call, and http://v4l2spec.bytesex.org/spec/r10944.htm
confirms that. Which also means, thatvivi.cdoes it wrongly. Mauro, you are listed as one of the authors ofvivi.c, and it looks like callingS_FMTon it with field != ANY && field != INTERLACED will produce-EINVAL, which seems to contradict the API. What is the correct behavious? Is this a bug invivi.c?
Yes, it is a bug at vivi. Could you please provide us a patch for it?
Cheers,
Mauro
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
S_FMT error handling (was Re: [PATCH v3] Add tw9910 driver)
(discussed shortly on IRC with Hans yesterday, so, added to cc:)
Quoted 11 lines · Mauro Carvalho Chehab
Quoted 7 lines · On Tue, 16 Dec 2008 11:09:21 +0100 (CET) Guennadi Liakhovetski…
so, here it is trying ANY... OTOH, the comment above says the driver shouldn't fail this call, and http://v4l2spec.bytesex.org/spec/r10944.htm
confirms that. Which also means, thatvivi.cdoes it wrongly. Mauro, you are listed as one of the authors ofvivi.c, and it looks like callingS_FMTon it with field != ANY && field != INTERLACED will produce-EINVAL, which seems to contradict the API. What is the correct behavious? Is this a bug invivi.c?
Quoted 1 line
Yes, it is a bug at vivi. Could you please provide us a patch for it?
I looked at several other drivers, all I have seen act in S_FMT a bit more creatively than the API requires. Do we really want to fix them all? TBH, I like the implementations better than the standard: we do provide TRY_FMT exactly for this purpose - for applications to figure out what is supported. And if they still don't obey, returning an error seems like a sane thing to do to me. Besides, modifying all drivers that behave wrongly with this respect seems not quite trivial - you have to select some supported format possibly close to the requested one... May we not just interpret such requests as "ambiguous," following [1]?
I could probably make a reasonable patch for vivi.c, but I don't think I would be able to fix this misbehaviour in all drivers.
[1] http://v4l2spec.bytesex.org/spec/r10944.htm
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 8 lines
Quoted 4 lines
Yes, that's fine. This depends on your application - whatever you use. And I would expect, if you first return
-EINVALin reply toFIELD_NONE, the application then will try either ANY or INTERLACED, and you will get a chance to select a suitable field.really ???
Now I'm using mplayer.
but mplayer doesn't try ANY or INTERLACED.
(snip)
Quoted 4 lines
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
--------------
Now, I found the reason why mplayer finish when try_fmt return -EINVAL in tw9910.
vivi.c use this functions on vivi_open
-----------
videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops, NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, sizeof(struct vivi_buffer), fh);
-----------
after that, fh->vb_vidq.field be V4L2_FIELD_INTERLACED. and vidioc_try_fmt_vid_cap doesn't get NONE field.
but icf->vb_vidq.field of soc_camera is V4L2_FIELD_NONE. therefore tw9910_try_fmt get NONE field.
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 5 lines
after that,
fh->vb_vidq.fieldbeV4L2_FIELD_INTERLACED. andvidioc_try_fmt_vid_capdoesn't get NONE field.but
icf->vb_vidq.fieldofsoc_cameraisV4L2_FIELD_NONE. thereforetw9910_try_fmtget NONE field.
Now I would like to add new "get_fmt" function to soc_camera_ops. And should I add "get_fmt" to soc_camera_host_ops too ?
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 2 lines
Now I would like to add new "
get_fmt" function tosoc_camera_ops. And should I add "get_fmt" tosoc_camera_host_opstoo ?
Sorry. "get_fmt" is not needed.
It is enough to simply modify sh_mobile_ceu_init_videobuf
V4L2_FIELD_NONE -> V4L2_FIELD_ANY
OK I will try to send 2 patches
o change NONE -> ANY on sh_mobile_ceu
o tw9910 driver
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list