Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Mauro, Hans Can I pull this patch as is via my tree, or shall we ask the author to split it into two: to add the subdev operation and to implement it for soc-camera? Thanks Guennadi On Thu, 20 Jan 2011, Qing Xu wrote: > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 37 + > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 ++ > 3 files changed, 40 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..50034b7 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum fsize_mbus = *fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus.pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus); > + if (ret < 0) > + return ret; > + > + *fsize = fsize_mbus; > + fsize->pixel_format = pixfmt; > + > + return 0; > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum > *); > unsigned int (*poll)(struct file *, poll_table *); > const struct v4l2_queryctrl *controls; > int num_controls; > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index b0316a7..0d482c9 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { > struct v4l2_dv_timings *timings); > int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, >enum v4l2_mbus_pixelcode *code); > + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, > + struct v4l2_frmsizeenum *fsize); > int (*g_mbus_fmt)(struct v4l2_subdev *sd, > struct v4l2_mbus_framefmt *fmt); > int (*try_mbus_fmt)(struct v4l2_subdev *sd, > -- > 1.6.3.3 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to ma
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Thanks! I am now prototyping Marvell camera driver to align with soc-camera architecture, may need some time to stabilize it. Our subdev driver now already follows those xxx_mbus_xxx operations. We hope we could finalize and submit our camera driver patch to open source this year. Thanks! -Qing -Original Message- From: Guennadi Liakhovetski [mailto:g.liakhovet...@gmx.de] Sent: 2011年1月21日 18:43 To: Hans Verkuil Cc: Qing Xu; linux-media@vger.kernel.org; Laurent Pinchart Subject: Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl On Fri, 21 Jan 2011, Hans Verkuil wrote: > On Friday, January 21, 2011 09:05:07 Guennadi Liakhovetski wrote: > > On Thu, 20 Jan 2011, Qing Xu wrote: > > > > > Hi Guennadi, Hans, > > > > > > I update this patch, I use enum_framesizes instead of > > > enum_mbus_fsizes, which is already defined in v4l2-subdev.h, > > > so, do not need to modify v4l2-subdev.h now. > > > > > > Are you ok with it? > > > > Hm, you see, this would mean, hijacking a "wrong" operation. This is one > > of those "wrong" subdevice operations, using fourcc formats to specify a > > data format on the video-bus between a subdevice (a sensor) and a sink (a > > host). Previously there have been more of such "wrong" operations, like > > .{g,s,try,enum}_fmt, all of those have been _gradually_ replaced by > > respective mediabus counterparts. While doing that we first added new > > operations with different names (with an extra "mbus_" in them), then > > ported all existing users over to them, and eventually removed the old > > "wrong" ones (Hans has done the dirtiest and most difficult part of that - > > porting and removing;)). Now, the .enum_framesizes() video subdev > > operation is also one such wrong API element. It has much fewer current > > users (ov7670.c and cafe_ccic.c - the OLPC project). > > Oops, I'd missed those. Those should be replaced with enum_mbus_framesizes. > Ditto for enum_frameintervals. via_camera.c uses it as well. > > > If we just blatantly > > re-use it with a media-bus code, it will be relatively harmless, imho, > > still, it will introduce an ambiguity. Of the above two drivers the sensor > > driver will not have to be changed at all, because it just ignores the > > pixel_format field altogether, cafe_ccic.c will have to be trivially > > ported, we'd just have to add a couple of lines, e.g. > > > > static int cafe_vidioc_enum_framesizes(struct file *filp, void *priv, > > struct v4l2_frmsizeenum *sizes) > > { > > struct cafe_camera *cam = priv; > > + __u32 fourcc = sizes->pixel_format; > > int ret; > > > > mutex_lock(&cam->s_mutex); > > + sizes->pixel_format = cam->mbus_code; > > ret = sensor_call(cam, video, enum_framesizes, sizes); > > mutex_unlock(&cam->s_mutex); > > + sizes->pixel_format = fourcc; > > return ret; > > } > > > > > > or something similar. So, that's certainly doable, still, I think, this > > would introduce a precedent of inconsistent naming - we'll have an > > operation, without an "mbus" in the name, operating at the media-bus > > level, which is not a very good idea, imho. Hans? > > I agree. > > First add new enum_mbus_framesizes and enum_mbus_frameintervals functions. > Then convert the three drivers that use this (ov7670.c, cafe_ccic.c and > via_camera.c) to these new ops. Next remove the old ones since nobody should > use them anymore. And finally add support for this to soc_camera. Right, but let me put this a bit more softly: I don't think Qing Xu _must_ now fix all those drivers, even though those changes are, perhaps, really trivial. As long as the new operations are added, if he chooses not to patch those 3 other drivers, it would be fine if he just does what concerns him (in fact, he doesn't have to do anything else, we still have his previous versions of the patches, we can just use them). If needed, even I could cook up patches for those 3 drivers, no big deal. > I can take your ov7670/cafe/via patches and test them and make a pull request > for them. I have other outstanding work for those drivers so I can take this > in as well. Since it is a big pain to test on the OLPC laptop I'd rather test > everything in one go :-) > > Laurent, it is a good idea if you took a look at this as well. Especially > since > you have similar patches in your media controller series: > > http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/26821 > > The framesize struct is much simp
Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Fri, 21 Jan 2011, Hans Verkuil wrote: > On Friday, January 21, 2011 09:05:07 Guennadi Liakhovetski wrote: > > On Thu, 20 Jan 2011, Qing Xu wrote: > > > > > Hi Guennadi, Hans, > > > > > > I update this patch, I use enum_framesizes instead of > > > enum_mbus_fsizes, which is already defined in v4l2-subdev.h, > > > so, do not need to modify v4l2-subdev.h now. > > > > > > Are you ok with it? > > > > Hm, you see, this would mean, hijacking a "wrong" operation. This is one > > of those "wrong" subdevice operations, using fourcc formats to specify a > > data format on the video-bus between a subdevice (a sensor) and a sink (a > > host). Previously there have been more of such "wrong" operations, like > > .{g,s,try,enum}_fmt, all of those have been _gradually_ replaced by > > respective mediabus counterparts. While doing that we first added new > > operations with different names (with an extra "mbus_" in them), then > > ported all existing users over to them, and eventually removed the old > > "wrong" ones (Hans has done the dirtiest and most difficult part of that - > > porting and removing;)). Now, the .enum_framesizes() video subdev > > operation is also one such wrong API element. It has much fewer current > > users (ov7670.c and cafe_ccic.c - the OLPC project). > > Oops, I'd missed those. Those should be replaced with enum_mbus_framesizes. > Ditto for enum_frameintervals. via_camera.c uses it as well. > > > If we just blatantly > > re-use it with a media-bus code, it will be relatively harmless, imho, > > still, it will introduce an ambiguity. Of the above two drivers the sensor > > driver will not have to be changed at all, because it just ignores the > > pixel_format field altogether, cafe_ccic.c will have to be trivially > > ported, we'd just have to add a couple of lines, e.g. > > > > static int cafe_vidioc_enum_framesizes(struct file *filp, void *priv, > > struct v4l2_frmsizeenum *sizes) > > { > > struct cafe_camera *cam = priv; > > + __u32 fourcc = sizes->pixel_format; > > int ret; > > > > mutex_lock(&cam->s_mutex); > > + sizes->pixel_format = cam->mbus_code; > > ret = sensor_call(cam, video, enum_framesizes, sizes); > > mutex_unlock(&cam->s_mutex); > > + sizes->pixel_format = fourcc; > > return ret; > > } > > > > > > or something similar. So, that's certainly doable, still, I think, this > > would introduce a precedent of inconsistent naming - we'll have an > > operation, without an "mbus" in the name, operating at the media-bus > > level, which is not a very good idea, imho. Hans? > > I agree. > > First add new enum_mbus_framesizes and enum_mbus_frameintervals functions. > Then convert the three drivers that use this (ov7670.c, cafe_ccic.c and > via_camera.c) to these new ops. Next remove the old ones since nobody should > use them anymore. And finally add support for this to soc_camera. Right, but let me put this a bit more softly: I don't think Qing Xu _must_ now fix all those drivers, even though those changes are, perhaps, really trivial. As long as the new operations are added, if he chooses not to patch those 3 other drivers, it would be fine if he just does what concerns him (in fact, he doesn't have to do anything else, we still have his previous versions of the patches, we can just use them). If needed, even I could cook up patches for those 3 drivers, no big deal. Thanks Guennadi > I can take your ov7670/cafe/via patches and test them and make a pull request > for them. I have other outstanding work for those drivers so I can take this > in as well. Since it is a big pain to test on the OLPC laptop I'd rather test > everything in one go :-) > > Laurent, it is a good idea if you took a look at this as well. Especially > since > you have similar patches in your media controller series: > > http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/26821 > > The framesize struct is much simplified here and any new code should probably > be close to what is proposed here. > > Regards, > > Hans > > > > > Thanks > > Guennadi > > > > > > > > -Qing > > > > > > -Original Message- > > > From: Qing Xu [mailto:qi...@marvell.com] > > > Sent: 2011Äê1ÔÂ21ÈÕ 9:48 > > > To: g.liakhovet...@gmx.de > > > Cc: linux-media@vger.kernel.org; Qing Xu > > > Subje
Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Friday, January 21, 2011 09:05:07 Guennadi Liakhovetski wrote: > On Thu, 20 Jan 2011, Qing Xu wrote: > > > Hi Guennadi, Hans, > > > > I update this patch, I use enum_framesizes instead of > > enum_mbus_fsizes, which is already defined in v4l2-subdev.h, > > so, do not need to modify v4l2-subdev.h now. > > > > Are you ok with it? > > Hm, you see, this would mean, hijacking a "wrong" operation. This is one > of those "wrong" subdevice operations, using fourcc formats to specify a > data format on the video-bus between a subdevice (a sensor) and a sink (a > host). Previously there have been more of such "wrong" operations, like > .{g,s,try,enum}_fmt, all of those have been _gradually_ replaced by > respective mediabus counterparts. While doing that we first added new > operations with different names (with an extra "mbus_" in them), then > ported all existing users over to them, and eventually removed the old > "wrong" ones (Hans has done the dirtiest and most difficult part of that - > porting and removing;)). Now, the .enum_framesizes() video subdev > operation is also one such wrong API element. It has much fewer current > users (ov7670.c and cafe_ccic.c - the OLPC project). Oops, I'd missed those. Those should be replaced with enum_mbus_framesizes. Ditto for enum_frameintervals. via_camera.c uses it as well. > If we just blatantly > re-use it with a media-bus code, it will be relatively harmless, imho, > still, it will introduce an ambiguity. Of the above two drivers the sensor > driver will not have to be changed at all, because it just ignores the > pixel_format field altogether, cafe_ccic.c will have to be trivially > ported, we'd just have to add a couple of lines, e.g. > > static int cafe_vidioc_enum_framesizes(struct file *filp, void *priv, > struct v4l2_frmsizeenum *sizes) > { > struct cafe_camera *cam = priv; > + __u32 fourcc = sizes->pixel_format; > int ret; > > mutex_lock(&cam->s_mutex); > + sizes->pixel_format = cam->mbus_code; > ret = sensor_call(cam, video, enum_framesizes, sizes); > mutex_unlock(&cam->s_mutex); > + sizes->pixel_format = fourcc; > return ret; > } > > > or something similar. So, that's certainly doable, still, I think, this > would introduce a precedent of inconsistent naming - we'll have an > operation, without an "mbus" in the name, operating at the media-bus > level, which is not a very good idea, imho. Hans? I agree. First add new enum_mbus_framesizes and enum_mbus_frameintervals functions. Then convert the three drivers that use this (ov7670.c, cafe_ccic.c and via_camera.c) to these new ops. Next remove the old ones since nobody should use them anymore. And finally add support for this to soc_camera. I can take your ov7670/cafe/via patches and test them and make a pull request for them. I have other outstanding work for those drivers so I can take this in as well. Since it is a big pain to test on the OLPC laptop I'd rather test everything in one go :-) Laurent, it is a good idea if you took a look at this as well. Especially since you have similar patches in your media controller series: http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/26821 The framesize struct is much simplified here and any new code should probably be close to what is proposed here. Regards, Hans > > Thanks > Guennadi > > > > > -Qing > > > > -Original Message- > > From: Qing Xu [mailto:qi...@marvell.com] > > Sent: 2011年1月21日 9:48 > > To: g.liakhovet...@gmx.de > > Cc: linux-media@vger.kernel.org; Qing Xu > > Subject: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl > > > > add vidioc_enum_framesizes implementation, follow default_g_parm() > > and g_mbus_fmt() method > > > > Signed-off-by: Qing Xu > > --- > > drivers/media/video/soc_camera.c | 37 > > + > > include/media/soc_camera.h |1 + > > 2 files changed, 38 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/media/video/soc_camera.c > > b/drivers/media/video/soc_camera.c > > index 052bd6d..7290107 100644 > > --- a/drivers/media/video/soc_camera.c > > +++ b/drivers/media/video/soc_camera.c > > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > > *priv, v4l2_std_id *a) > > return v4l2_subdev_call(sd, core, s_std, *a); > > } > > > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > > +
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Thu, 20 Jan 2011, Qing Xu wrote: > Hi Guennadi, Hans, > > I update this patch, I use enum_framesizes instead of > enum_mbus_fsizes, which is already defined in v4l2-subdev.h, > so, do not need to modify v4l2-subdev.h now. > > Are you ok with it? Hm, you see, this would mean, hijacking a "wrong" operation. This is one of those "wrong" subdevice operations, using fourcc formats to specify a data format on the video-bus between a subdevice (a sensor) and a sink (a host). Previously there have been more of such "wrong" operations, like .{g,s,try,enum}_fmt, all of those have been _gradually_ replaced by respective mediabus counterparts. While doing that we first added new operations with different names (with an extra "mbus_" in them), then ported all existing users over to them, and eventually removed the old "wrong" ones (Hans has done the dirtiest and most difficult part of that - porting and removing;)). Now, the .enum_framesizes() video subdev operation is also one such wrong API element. It has much fewer current users (ov7670.c and cafe_ccic.c - the OLPC project). If we just blatantly re-use it with a media-bus code, it will be relatively harmless, imho, still, it will introduce an ambiguity. Of the above two drivers the sensor driver will not have to be changed at all, because it just ignores the pixel_format field altogether, cafe_ccic.c will have to be trivially ported, we'd just have to add a couple of lines, e.g. static int cafe_vidioc_enum_framesizes(struct file *filp, void *priv, struct v4l2_frmsizeenum *sizes) { struct cafe_camera *cam = priv; + __u32 fourcc = sizes->pixel_format; int ret; mutex_lock(&cam->s_mutex); + sizes->pixel_format = cam->mbus_code; ret = sensor_call(cam, video, enum_framesizes, sizes); mutex_unlock(&cam->s_mutex); + sizes->pixel_format = fourcc; return ret; } or something similar. So, that's certainly doable, still, I think, this would introduce a precedent of inconsistent naming - we'll have an operation, without an "mbus" in the name, operating at the media-bus level, which is not a very good idea, imho. Hans? Thanks Guennadi > > -Qing > > -Original Message- > From: Qing Xu [mailto:qi...@marvell.com] > Sent: 2011年1月21日 9:48 > To: g.liakhovet...@gmx.de > Cc: linux-media@vger.kernel.org; Qing Xu > Subject: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl > > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 37 + > include/media/soc_camera.h |1 + > 2 files changed, 38 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..7290107 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > +struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum fsize_mbus = *fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus.pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus); > + if (ret < 0) > + return ret; > + > + *fsize = fsize_mbus; > + fsize->pixel_format = pixfmt; > + > + return 0; > +} >
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Hi Guennadi, Hans, I update this patch, I use enum_framesizes instead of enum_mbus_fsizes, which is already defined in v4l2-subdev.h, so, do not need to modify v4l2-subdev.h now. Are you ok with it? -Qing -Original Message- From: Qing Xu [mailto:qi...@marvell.com] Sent: 2011年1月21日 9:48 To: g.liakhovet...@gmx.de Cc: linux-media@vger.kernel.org; Qing Xu Subject: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl add vidioc_enum_framesizes implementation, follow default_g_parm() and g_mbus_fmt() method Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 37 + include/media/soc_camera.h |1 + 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..7290107 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum fsize_mbus = *fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus.pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus); + if (ret < 0) + return ret; + + *fsize = fsize_mbus; + fsize->pixel_format = pixfmt; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; -- 1.6.3.3
[PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
add vidioc_enum_framesizes implementation, follow default_g_parm() and g_mbus_fmt() method Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 37 + include/media/soc_camera.h |1 + 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..7290107 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum fsize_mbus = *fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus.pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus); + if (ret < 0) + return ret; + + *fsize = fsize_mbus; + fsize->pixel_format = pixfmt; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; -- 1.6.3.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://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Hi Guennadi, Thanks for your careful review and patient and your time!! -Qing -Original Message- From: Guennadi Liakhovetski [mailto:g.liakhovet...@gmx.de] Sent: 2011年1月20日 16:28 To: Qing Xu Cc: Linux Media Mailing List; Hans Verkuil Subject: Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl On Thu, 20 Jan 2011, Qing Xu wrote: > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method Yes, thanks, that's more like what I meant! Now, this patch also touches a generic v4l2 file include/media/v4l2-subdev.h, and that in a very essential way - it ads a new API. So, we either need an ack from someone, maintaining the v4l2-subdev API, or we will have to split that part off and apply it first. Hans? Thanks Guennadi > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 37 + > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 ++ > 3 files changed, 40 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..50034b7 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum fsize_mbus = *fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus.pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus); > + if (ret < 0) > + return ret; > + > + *fsize = fsize_mbus; > + fsize->pixel_format = pixfmt; > + > + return 0; > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum > *); > unsigned int (*poll)(struct file *, poll_table *); > const struct v4l2_queryctrl *controls; > int num_controls; > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index b0316a7..0d482c9 1006
Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Thu, 20 Jan 2011, Qing Xu wrote: > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method Yes, thanks, that's more like what I meant! Now, this patch also touches a generic v4l2 file include/media/v4l2-subdev.h, and that in a very essential way - it ads a new API. So, we either need an ack from someone, maintaining the v4l2-subdev API, or we will have to split that part off and apply it first. Hans? Thanks Guennadi > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 37 + > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 ++ > 3 files changed, 40 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..50034b7 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum fsize_mbus = *fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus.pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus); > + if (ret < 0) > + return ret; > + > + *fsize = fsize_mbus; > + fsize->pixel_format = pixfmt; > + > + return 0; > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum > *); > unsigned int (*poll)(struct file *, poll_table *); > const struct v4l2_queryctrl *controls; > int num_controls; > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index b0316a7..0d482c9 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { > struct v4l2_dv_timings *timings); > int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, >enum v4l2_mbus_pixelcode *code); > + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, > + struct v4l2_frmsizeenum *fsize); > int (*g_mbus_fmt)(struct v4l2_subdev *sd, > struct v4l2_mbus_framefmt *fmt); > int (*try_mbus_fmt)(struct v4l2_subdev *sd, > -- > 1.6.3.3 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Softw
[PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
add vidioc_enum_framesizes implementation, follow default_g_parm() and g_mbus_fmt() method Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 37 + include/media/soc_camera.h |1 + include/media/v4l2-subdev.h |2 ++ 3 files changed, 40 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..50034b7 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,31 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum fsize_mbus = *fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus.pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus); + if (ret < 0) + return ret; + + *fsize = fsize_mbus; + fsize->pixel_format = pixfmt; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1229,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1338,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b0316a7..0d482c9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_timings *timings); int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code); + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, +struct v4l2_frmsizeenum *fsize); int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); int (*try_mbus_fmt)(struct v4l2_subdev *sd, -- 1.6.3.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://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Hm, sorry! My below comment: On Wed, 19 Jan 2011, Guennadi Liakhovetski wrote: > On Tue, 18 Jan 2011, Qing Xu wrote: [snip] > > @@ -1160,6 +1169,28 @@ static int default_s_parm(struct soc_camera_device > > *icd, > > return v4l2_subdev_call(sd, video, s_parm, parm); > > } > > > > +static int default_enum_fsizes(struct soc_camera_device *icd, > > + struct v4l2_frmsizeenum *fsize) > > +{ > > + int ret; > > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > > + const struct soc_camera_format_xlate *xlate; > > + __u32 pixfmt = fsize->pixel_format; > > + struct v4l2_frmsizeenum *fsize_mbus = fsize; > > Please, test your patches before posting! The above should have been was certainly wrong! Your line was correct syntactically, still, I'd like to have a slightly different version, please see my last mail to you. Sorry again! Guennadi > > + struct v4l2_frmsizeenum *fsize_mbus = *fsize; > > > + > > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > > + if (!xlate) > > + return -EINVAL; > > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > > + fsize_mbus->pixel_format = xlate->code; > > + > > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); > > + if (ret < 0) > > + return ret; > > + > > + return 0; > > Yes, almost. You're still missing one important point though: you're not > returning the result to the user... So, before your "return 0;" you have > to add two more lines: > > + *fsize = *fsize_mbus; > + fsize->pixel_format = pixfmt; > > Thanks > Guennadi > > > +} > > + > > static void soc_camera_device_init(struct device *dev, void *pdata) > > { > > dev->platform_data = pdata; > > @@ -1195,6 +1226,8 @@ int soc_camera_host_register(struct soc_camera_host > > *ici) > > ici->ops->set_parm = default_s_parm; > > if (!ici->ops->get_parm) > > ici->ops->get_parm = default_g_parm; > > + if (!ici->ops->enum_fsizes) > > + ici->ops->enum_fsizes = default_enum_fsizes; > > > > mutex_lock(&list_lock); > > list_for_each_entry(ix, &hosts, list) { > > @@ -1302,6 +1335,7 @@ static const struct v4l2_ioctl_ops > > soc_camera_ioctl_ops = { > > .vidioc_g_input = soc_camera_g_input, > > .vidioc_s_input = soc_camera_s_input, > > .vidioc_s_std= soc_camera_s_std, > > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > > .vidioc_reqbufs = soc_camera_reqbufs, > > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > > .vidioc_querybuf = soc_camera_querybuf, > > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > > index 86e3631..6e4800c 100644 > > --- a/include/media/soc_camera.h > > +++ b/include/media/soc_camera.h > > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm > > *); > > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm > > *); > > + int (*enum_fsizes)(struct soc_camera_device *, struct > > v4l2_frmsizeenum *); > > unsigned int (*poll)(struct file *, poll_table *); > > const struct v4l2_queryctrl *controls; > > int num_controls; > > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > > index b0316a7..0d482c9 100644 > > --- a/include/media/v4l2-subdev.h > > +++ b/include/media/v4l2-subdev.h > > @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { > > struct v4l2_dv_timings *timings); > > int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, > > enum v4l2_mbus_pixelcode *code); > > + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, > > +struct v4l2_frmsizeenum *fsize); > > int (*g_mbus_fmt)(struct v4l2_subdev *sd, > > struct v4l2_mbus_framefmt *fmt); > > int (*try_mbus_fmt)(struct v4l2_subdev *sd, > > -- > > 1.6.3.3 > > > > > > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/ > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Thu, 20 Jan 2011, Qing Xu wrote: > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 36 > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 ++ > 3 files changed, 39 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..c89010a 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,30 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum *fsize_mbus = fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus->pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); > + if (ret < 0) > + return ret; > + > + fsize->pixel_format = pixfmt; NAK. Please do it the way I suggested in my last email or explain why you think, it was wrong. Guennadi > + > + return 0; > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1228,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1337,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum > *); > unsigned int (*poll)(struct file *, poll_table *); > const struct v4l2_queryctrl *controls; > int num_controls; > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index b0316a7..0d482c9 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { > struct v4l2_dv_timings *timings); > int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, >enum v4l2_mbus_pixelcode *code); > + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, > + struct v4l2_frmsizeenum *fsize); > int (*g_mbus_fmt)(struct v4l2_subdev *sd, > struct v4l2_mbus_framefmt *fmt); > int (*try_mbus_fmt)(struct v4l2_subdev *sd, > -- > 1.6.3.3 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] [media] v4l: soc-camera: add enum-frame-size ioctl
add vidioc_enum_framesizes implementation, follow default_g_parm() and g_mbus_fmt() method Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 36 include/media/soc_camera.h |1 + include/media/v4l2-subdev.h |2 ++ 3 files changed, 39 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..c89010a 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,30 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum *fsize_mbus = fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus->pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); + if (ret < 0) + return ret; + + fsize->pixel_format = pixfmt; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1228,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1337,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b0316a7..0d482c9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_timings *timings); int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code); + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, +struct v4l2_frmsizeenum *fsize); int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); int (*try_mbus_fmt)(struct v4l2_subdev *sd, -- 1.6.3.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://vger.kernel.org/majordomo-info.html
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Tue, 18 Jan 2011, Qing Xu wrote: > Hi Guennadi, > > Thanks for reviewing my patch! I update it again following your > suggestion, please take your time to review it again, Thanks a lot! > > -Qing > > Email: qi...@marvell.com > Application Processor Systems Engineering, > Marvell Technology Group Ltd. > > -Original Message- > From: Qing Xu [mailto:qi...@marvell.com] > Sent: 2011年1月19日 10:37 > To: g.liakhovet...@gmx.de > Cc: linux-media@vger.kernel.org; Qing Xu > Subject: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl > > add vidioc_enum_framesizes implementation > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 34 ++ > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 ++ > 3 files changed, 37 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..5e0aa9e 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > +struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + return ici->ops->enum_fsizes(icd, fsize); > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1169,28 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + struct v4l2_frmsizeenum *fsize_mbus = fsize; Please, test your patches before posting! The above should have been + struct v4l2_frmsizeenum *fsize_mbus = *fsize; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) > + return -EINVAL; > + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ > + fsize_mbus->pixel_format = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); > + if (ret < 0) > + return ret; > + > + return 0; Yes, almost. You're still missing one important point though: you're not returning the result to the user... So, before your "return 0;" you have to add two more lines: + *fsize = *fsize_mbus; + fsize->pixel_format = pixfmt; Thanks Guennadi > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1226,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1335,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_came
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Hi Guennadi, Thanks for reviewing my patch! I update it again following your suggestion, please take your time to review it again, Thanks a lot! -Qing Email: qi...@marvell.com Application Processor Systems Engineering, Marvell Technology Group Ltd. -Original Message- From: Qing Xu [mailto:qi...@marvell.com] Sent: 2011年1月19日 10:37 To: g.liakhovet...@gmx.de Cc: linux-media@vger.kernel.org; Qing Xu Subject: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl add vidioc_enum_framesizes implementation Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 34 ++ include/media/soc_camera.h |1 + include/media/v4l2-subdev.h |2 ++ 3 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..5e0aa9e 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,28 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum *fsize_mbus = fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus->pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); + if (ret < 0) + return ret; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1226,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1335,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b0316a7..0d482c9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_timings *timings); int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code); + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, +struct v4l2_frmsizeenum *fsize); int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); int (*try_mbus_fmt)(struct v4l2_subdev *sd, -- 1.6.3.3 N�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{���bj)��骅w*jg�报�茛j/�赇z罐���2���ㄨ��&�)摺�a囤���G���h��j:+v���w��佶
[PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
add vidioc_enum_framesizes implementation Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 34 ++ include/media/soc_camera.h |1 + include/media/v4l2-subdev.h |2 ++ 3 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..5e0aa9e 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,15 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + return ici->ops->enum_fsizes(icd, fsize); +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1169,28 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + struct v4l2_frmsizeenum *fsize_mbus = fsize; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) + return -EINVAL; + /* map xlate-code to pixel_format, sensor only handle xlate-code*/ + fsize_mbus->pixel_format = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, fsize_mbus); + if (ret < 0) + return ret; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1226,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1335,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b0316a7..0d482c9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_timings *timings); int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code); + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, +struct v4l2_frmsizeenum *fsize); int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); int (*try_mbus_fmt)(struct v4l2_subdev *sd, -- 1.6.3.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://vger.kernel.org/majordomo-info.html
Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Mon, 17 Jan 2011, Qing Xu wrote: > add vidioc_enum_framesizes implementation, follow default_g_parm() > and g_mbus_fmt() method > > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 42 > ++ > include/media/soc_camera.h |1 + > include/media/v4l2-subdev.h |2 + > 3 files changed, 45 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..35260a5 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,18 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_fsizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); > + > + if (ici->ops->enum_fsizes) > + return ici->ops->enum_fsizes(icd, fsize); > + > + return -ENOIOCTLCMD; Do you need this? We don't do this with other similar operations: if none is provided by the user, we supply our own default, so, don't think we need to check for NULL here. > +} > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1160,6 +1172,33 @@ static int default_s_parm(struct soc_camera_device > *icd, > return v4l2_subdev_call(sd, video, s_parm, parm); > } > > +static int default_enum_fsizes(struct soc_camera_device *icd, > + struct v4l2_frmsizeenum *fsize) > +{ > + int ret; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + struct v4l2_mbus_framefmt mf; > + const struct soc_camera_format_xlate *xlate; > + __u32 pixfmt = fsize->pixel_format; > + > + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); > + if (!xlate) { > + return -EINVAL; > + } Superfluous braces. > + > + mf.code = xlate->code; > + > + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &mf); > + if (ret < 0) > + return ret; > + > + fsize->discrete.height = mf.height; > + fsize->discrete.width = mf.width; > + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; Hmm, no, that's not quite what I meant. I meant something like this: + struct v4l2_frmsizeenum fsize_mbus = *fsize; ... + fsize_mbus.pixel_format = xlate->code; + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus); Of course, you'll have to change your prototypes in the header respectively. With your solution you hard-code only one discrete size, which doesn't seem like a good idea to me. Thanks Guennadi > + > + return 0; > +} > + > static void soc_camera_device_init(struct device *dev, void *pdata) > { > dev->platform_data = pdata; > @@ -1195,6 +1234,8 @@ int soc_camera_host_register(struct soc_camera_host > *ici) > ici->ops->set_parm = default_s_parm; > if (!ici->ops->get_parm) > ici->ops->get_parm = default_g_parm; > + if (!ici->ops->enum_fsizes) > + ici->ops->enum_fsizes = default_enum_fsizes; > > mutex_lock(&list_lock); > list_for_each_entry(ix, &hosts, list) { > @@ -1302,6 +1343,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_fsizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h > index 86e3631..6e4800c 100644 > --- a/include/media/soc_camera.h > +++ b/include/media/soc_camera.h > @@ -85,6 +85,7 @@ struct soc_camera_host_ops { > int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); > int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); > + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum > *); > unsigned int (*poll)(struct file *, poll_table *); > const struct v4l2_queryctrl *controls; > int num_controls; > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index b0316a7..d4e0d80 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { > struct v4l2_dv_timings *timings); > int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, >enum v4l2_mbus_pixelcode *code)
[PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
add vidioc_enum_framesizes implementation, follow default_g_parm() and g_mbus_fmt() method Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 42 ++ include/media/soc_camera.h |1 + include/media/v4l2-subdev.h |2 + 3 files changed, 45 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..35260a5 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,18 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_fsizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); + + if (ici->ops->enum_fsizes) + return ici->ops->enum_fsizes(icd, fsize); + + return -ENOIOCTLCMD; +} + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1160,6 +1172,33 @@ static int default_s_parm(struct soc_camera_device *icd, return v4l2_subdev_call(sd, video, s_parm, parm); } +static int default_enum_fsizes(struct soc_camera_device *icd, + struct v4l2_frmsizeenum *fsize) +{ + int ret; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + struct v4l2_mbus_framefmt mf; + const struct soc_camera_format_xlate *xlate; + __u32 pixfmt = fsize->pixel_format; + + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) { + return -EINVAL; + } + + mf.code = xlate->code; + + ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &mf); + if (ret < 0) + return ret; + + fsize->discrete.height = mf.height; + fsize->discrete.width = mf.width; + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; + + return 0; +} + static void soc_camera_device_init(struct device *dev, void *pdata) { dev->platform_data = pdata; @@ -1195,6 +1234,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ici->ops->set_parm = default_s_parm; if (!ici->ops->get_parm) ici->ops->get_parm = default_g_parm; + if (!ici->ops->enum_fsizes) + ici->ops->enum_fsizes = default_enum_fsizes; mutex_lock(&list_lock); list_for_each_entry(ix, &hosts, list) { @@ -1302,6 +1343,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 86e3631..6e4800c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -85,6 +85,7 @@ struct soc_camera_host_ops { int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); + int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); unsigned int (*poll)(struct file *, poll_table *); const struct v4l2_queryctrl *controls; int num_controls; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b0316a7..d4e0d80 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -275,6 +275,8 @@ struct v4l2_subdev_video_ops { struct v4l2_dv_timings *timings); int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code); + int (*enum_mbus_fsizes)(struct v4l2_subdev *sd, +struct v4l2_mbus_framefmt *fmt); int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); int (*try_mbus_fmt)(struct v4l2_subdev *sd, -- 1.6.3.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://vger.kernel.org/majordomo-info.html
Re: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
Hi Guennadi, On Monday 10 January 2011 09:20:05 Guennadi Liakhovetski wrote: > On Sun, 9 Jan 2011, Qing Xu wrote: > > On Fri, 7 Jan 2011, Guennadi Liakhovetski wrote: > > > On Fri, 7 Jan 2011, Qing Xu wrote: > > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > > > special handling in soc-camera core. > > > > > > Hm, no, guess what? I don't think this can work. The parameter, that > > > this routine gets from the user struct v4l2_frmsizeenum contains a > > > member pixel_format, which is a fourcc code. Whereas subdevices don't > > > deal with them, they deal with mediabus codes. It is the same problem > > > as with old s/g/try/enum_fmt, which we replaced with respective mbus > > > variants. So, we either have to add our own .enum_mbus_framesizes > > > video subdevice operation, or we abuse this one, but interpret the > > > pixel_format field as a media-bus code. > > > > > > Currently I only see one subdev driver, that implements this API: > > > ov7670.c, and it just happily ignores the pixel_format altogether... > > > > > > Hans, Laurent, what do you think? > > > > > > In the soc-camera case you will have to use > > > soc_camera_xlate_by_fourcc() to convert to media-bus code from fourcc. > > > A nit-pick: please, follow the style of the file, that you patch and > > > don't add double empty lines between functions. > > > > > > A side question: why do you need this format at all? Is it for some > > > custom > > > > > > Sorry, I meant to ask - what do you need this operation / ioctl() for? > > > > Before we launch camera application, we will use enum-frame-size ioctl > > to get all frame size that the sensor supports, and show all options in > > UI menu, then the customers could choose a size, and tell camera driver. > > And if the camera supports ranges of sizes? Or doesn't implement this > ioctl() at all? Remember, that this is an optional ioctl(). Would your > application just fail? Or you could provide a slider to let the user > select a size from a range, then just issue an s_fmt and use whatever it > returns... This is something you'd do for a generic application > > > If use mbus structure pass to sensor, we need to modify the second > > parameter definition, it will contain both mbus code information and > > width/height ingotmation: > > int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum > > *fsize); > > > > or use g_mbus_fmt instead: > > int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt > > *fmt); soc_camera_enum_framesizes() > > { > > > > ... > > return v4l2_subdev_call(sd, video, g_mbus_fmt, fsize);//typo, I > > mean "g_mbus_fmt" > > > > } > > > > What do you think? > > In any case therer needs to be a possibility for host drivers to override > this routine, so, please, do something similar, to what default_g_crop() / > default_s_crop() / default_cropcap() / default_g_parm() / default_s_parm() > do: add a host operation and provide a default implementation for it. And > since noone seems to care enough, I think, we can just abuse struct > v4l2_frmsizeenum for now, just make sure to rewrite pixel_format to a > media-bus code, and restore it before returning to the caller. I like the .enum_mbus_framesizes better, but I could live with a hack until if you convert soc_camera to use subdev pad-level operations when the MC will be available. -- Regards, Laurent Pinchart -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Sun, 9 Jan 2011, Qing Xu wrote: > On Mon, 10 Jan 2011, Qing Xu wrote: > > > On Fri, 7 Jan 2011, Guennadi Liakhovetski wrote: > > > On Fri, 7 Jan 2011, Qing Xu wrote: > > > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > > special handling in soc-camera core. > > > > Hm, no, guess what? I don't think this can work. The parameter, that this > > routine gets from the user struct v4l2_frmsizeenum contains a member > > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > > them, they deal with mediabus codes. It is the same problem as with old > > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > > either have to add our own .enum_mbus_framesizes video subdevice > > operation, or we abuse this one, but interpret the pixel_format field as a > > media-bus code. > > > > Currently I only see one subdev driver, that implements this API: > > ov7670.c, and it just happily ignores the pixel_format altogether... > > > > Hans, Laurent, what do you think? > > > > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > > to convert to media-bus code from fourcc. A nit-pick: please, follow the > > style of the file, that you patch and don't add double empty lines between > > functions. > > > > A side question: why do you need this format at all? Is it for some custom > > > Sorry, I meant to ask - what do you need this operation / ioctl() for? > > Hi Guennadi, > > Before we launch camera application, we will use enum-frame-size ioctl > to get all frame size that the sensor supports, and show all options in > UI menu, then the customers could choose a size, and tell camera driver. And if the camera supports ranges of sizes? Or doesn't implement this ioctl() at all? Remember, that this is an optional ioctl(). Would your application just fail? Or you could provide a slider to let the user select a size from a range, then just issue an s_fmt and use whatever it returns... This is something you'd do for a generic application > If use mbus structure pass to sensor, we need to modify the second > parameter definition, it will contain both mbus code information and > width/height ingotmation: > int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum > *fsize); > > or use g_mbus_fmt instead: > int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); > soc_camera_enum_framesizes() > { > ... > return v4l2_subdev_call(sd, video, g_mbus_fmt, fsize);//typo, I mean > "g_mbus_fmt" > } > > What do you think? In any case therer needs to be a possibility for host drivers to override this routine, so, please, do something similar, to what default_g_crop() / default_s_crop() / default_cropcap() / default_g_parm() / default_s_parm() do: add a host operation and provide a default implementation for it. And since noone seems to care enough, I think, we can just abuse struct v4l2_frmsizeenum for now, just make sure to rewrite pixel_format to a media-bus code, and restore it before returning to the caller. Thanks Guennadi > Thanks! > Qing > > > application? What is your use-case, that makes try_fmt / s_fmt > > insufficient for you and how does enum_framesizes help you? > > > > Thanks > > Guennadi > > > > > > > > Signed-off-by: Kassey Lee > > > Signed-off-by: Qing Xu > > > --- > > > drivers/media/video/soc_camera.c | 11 +++ > > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > > > diff --git a/drivers/media/video/soc_camera.c > > > b/drivers/media/video/soc_camera.c > > > index 052bd6d..11715fb 100644 > > > --- a/drivers/media/video/soc_camera.c > > > +++ b/drivers/media/video/soc_camera.c > > > @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void > > > *priv, v4l2_std_id *a) > > > return v4l2_subdev_call(sd, core, s_std, *a); > > > } > > > > > > +static int soc_camera_enum_framesizes(struct file *file, void *fh, > > > +struct v4l2_frmsizeenum *fsize) > > > +{ > > > + struct soc_camera_device *icd = file->private_data; > > > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > > > + > > > + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); > > > +} > > > + > > > + > > > static int soc_camera_reqbufs(struct file *file, void *priv, > > > struct v4l2_requestbuffers *p) > > > { > > > @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops > > > soc_camera_ioctl_ops = { > > > .vidioc_g_input = soc_camera_g_input, > > > .vidioc_s_input = soc_camera_s_input, > > > .vidioc_s_std= soc_camera_s_std, > > > + .vidioc_enum_framesizes = soc_camera_enum_framesizes, > > > .vidioc_reqbufs = soc_camera_reqbufs, > > > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > > > .vidioc_querybuf = soc_camera_querybuf, > > > -- > > > 1.6.3.3 > > > > > > > --- > > Guennadi Liakhovetski, Ph.D. >
RE: [PATCH] [media] v4l: soc-camera: add enum-frame-size ioctl
On Mon, 10 Jan 2011, Qing Xu wrote: > On Fri, 7 Jan 2011, Guennadi Liakhovetski wrote: > On Fri, 7 Jan 2011, Qing Xu wrote: > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > special handling in soc-camera core. > > Hm, no, guess what? I don't think this can work. The parameter, that this > routine gets from the user struct v4l2_frmsizeenum contains a member > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > them, they deal with mediabus codes. It is the same problem as with old > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > either have to add our own .enum_mbus_framesizes video subdevice > operation, or we abuse this one, but interpret the pixel_format field as a > media-bus code. > > Currently I only see one subdev driver, that implements this API: > ov7670.c, and it just happily ignores the pixel_format altogether... > > Hans, Laurent, what do you think? > > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > to convert to media-bus code from fourcc. A nit-pick: please, follow the > style of the file, that you patch and don't add double empty lines between > functions. > > A side question: why do you need this format at all? Is it for some custom > Sorry, I meant to ask - what do you need this operation / ioctl() for? Hi Guennadi, Before we launch camera application, we will use enum-frame-size ioctl to get all frame size that the sensor supports, and show all options in UI menu, then the customers could choose a size, and tell camera driver. If use mbus structure pass to sensor, we need to modify the second parameter definition, it will contain both mbus code information and width/height ingotmation: int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); or use g_mbus_fmt instead: int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); soc_camera_enum_framesizes() { ... return v4l2_subdev_call(sd, video, g_mbus_fmt, fsize);//typo, I mean "g_mbus_fmt" } What do you think? Thanks! Qing > application? What is your use-case, that makes try_fmt / s_fmt > insufficient for you and how does enum_framesizes help you? > > Thanks > Guennadi > > > > > Signed-off-by: Kassey Lee > > Signed-off-by: Qing Xu > > --- > > drivers/media/video/soc_camera.c | 11 +++ > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/media/video/soc_camera.c > > b/drivers/media/video/soc_camera.c > > index 052bd6d..11715fb 100644 > > --- a/drivers/media/video/soc_camera.c > > +++ b/drivers/media/video/soc_camera.c > > @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void > > *priv, v4l2_std_id *a) > > return v4l2_subdev_call(sd, core, s_std, *a); > > } > > > > +static int soc_camera_enum_framesizes(struct file *file, void *fh, > > +struct v4l2_frmsizeenum *fsize) > > +{ > > + struct soc_camera_device *icd = file->private_data; > > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > > + > > + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); > > +} > > + > > + > > static int soc_camera_reqbufs(struct file *file, void *priv, > > struct v4l2_requestbuffers *p) > > { > > @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops > > soc_camera_ioctl_ops = { > > .vidioc_g_input = soc_camera_g_input, > > .vidioc_s_input = soc_camera_s_input, > > .vidioc_s_std= soc_camera_s_std, > > + .vidioc_enum_framesizes = soc_camera_enum_framesizes, > > .vidioc_reqbufs = soc_camera_reqbufs, > > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > > .vidioc_querybuf = soc_camera_querybuf, > > -- > > 1.6.3.3 > > > > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/ > -- > 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 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Mon, 10 Jan 2011, Qing Xu wrote: > On Fri, 7 Jan 2011, Guennadi Liakhovetski wrote: > On Fri, 7 Jan 2011, Qing Xu wrote: > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > special handling in soc-camera core. > > Hm, no, guess what? I don't think this can work. The parameter, that this > routine gets from the user struct v4l2_frmsizeenum contains a member > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > them, they deal with mediabus codes. It is the same problem as with old > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > either have to add our own .enum_mbus_framesizes video subdevice > operation, or we abuse this one, but interpret the pixel_format field as a > media-bus code. > > Currently I only see one subdev driver, that implements this API: > ov7670.c, and it just happily ignores the pixel_format altogether... > > Hans, Laurent, what do you think? > > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > to convert to media-bus code from fourcc. A nit-pick: please, follow the > style of the file, that you patch and don't add double empty lines between > functions. > > A side question: why do you need this format at all? Is it for some custom > Sorry, I meant to ask - what do you need this operation / ioctl() for? Hi Guennadi, Before we launch camera application, we will use enum-frame-size ioctl to get all frame size that the sensor supports, and show all options in UI menu, then the customers could choose a size, and tell camera driver. If use mbus structure pass to sensor, we need to modify the second parameter definition, it will contain both mbus code information and width/height ingotmation: int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); or use g_mbus_fmt instead: int (*g_mbus_fmt)(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt); soc_camera_enum_framesizes() { ... return v4l2_subdev_call(sd, video, enum_framesizes, fsize); } What do you think? Thanks! Qing > application? What is your use-case, that makes try_fmt / s_fmt > insufficient for you and how does enum_framesizes help you? > > Thanks > Guennadi > > > > > Signed-off-by: Kassey Lee > > Signed-off-by: Qing Xu > > --- > > drivers/media/video/soc_camera.c | 11 +++ > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/media/video/soc_camera.c > > b/drivers/media/video/soc_camera.c > > index 052bd6d..11715fb 100644 > > --- a/drivers/media/video/soc_camera.c > > +++ b/drivers/media/video/soc_camera.c > > @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void > > *priv, v4l2_std_id *a) > > return v4l2_subdev_call(sd, core, s_std, *a); > > } > > > > +static int soc_camera_enum_framesizes(struct file *file, void *fh, > > +struct v4l2_frmsizeenum *fsize) > > +{ > > + struct soc_camera_device *icd = file->private_data; > > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > > + > > + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); > > +} > > + > > + > > static int soc_camera_reqbufs(struct file *file, void *priv, > > struct v4l2_requestbuffers *p) > > { > > @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops > > soc_camera_ioctl_ops = { > > .vidioc_g_input = soc_camera_g_input, > > .vidioc_s_input = soc_camera_s_input, > > .vidioc_s_std= soc_camera_s_std, > > + .vidioc_enum_framesizes = soc_camera_enum_framesizes, > > .vidioc_reqbufs = soc_camera_reqbufs, > > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > > .vidioc_querybuf = soc_camera_querybuf, > > -- > > 1.6.3.3 > > > > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/ > -- > 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 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Fri, 7 Jan 2011, Guennadi Liakhovetski wrote: > On Fri, 7 Jan 2011, Qing Xu wrote: > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > special handling in soc-camera core. > > Hm, no, guess what? I don't think this can work. The parameter, that this > routine gets from the user struct v4l2_frmsizeenum contains a member > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > them, they deal with mediabus codes. It is the same problem as with old > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > either have to add our own .enum_mbus_framesizes video subdevice > operation, or we abuse this one, but interpret the pixel_format field as a > media-bus code. > > Currently I only see one subdev driver, that implements this API: > ov7670.c, and it just happily ignores the pixel_format altogether... > > Hans, Laurent, what do you think? > > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > to convert to media-bus code from fourcc. A nit-pick: please, follow the > style of the file, that you patch and don't add double empty lines between > functions. > > A side question: why do you need this format at all? Is it for some custom Sorry, I meant to ask - what do you need this operation / ioctl() for? Thanks Guennadi > application? What is your use-case, that makes try_fmt / s_fmt > insufficient for you and how does enum_framesizes help you? > > Thanks > Guennadi > > > > > Signed-off-by: Kassey Lee > > Signed-off-by: Qing Xu > > --- > > drivers/media/video/soc_camera.c | 11 +++ > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/media/video/soc_camera.c > > b/drivers/media/video/soc_camera.c > > index 052bd6d..11715fb 100644 > > --- a/drivers/media/video/soc_camera.c > > +++ b/drivers/media/video/soc_camera.c > > @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void > > *priv, v4l2_std_id *a) > > return v4l2_subdev_call(sd, core, s_std, *a); > > } > > > > +static int soc_camera_enum_framesizes(struct file *file, void *fh, > > +struct v4l2_frmsizeenum *fsize) > > +{ > > + struct soc_camera_device *icd = file->private_data; > > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > > + > > + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); > > +} > > + > > + > > static int soc_camera_reqbufs(struct file *file, void *priv, > > struct v4l2_requestbuffers *p) > > { > > @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops > > soc_camera_ioctl_ops = { > > .vidioc_g_input = soc_camera_g_input, > > .vidioc_s_input = soc_camera_s_input, > > .vidioc_s_std= soc_camera_s_std, > > + .vidioc_enum_framesizes = soc_camera_enum_framesizes, > > .vidioc_reqbufs = soc_camera_reqbufs, > > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > > .vidioc_querybuf = soc_camera_querybuf, > > -- > > 1.6.3.3 > > > > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/ > -- > 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 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Fri, 7 Jan 2011, Laurent Pinchart wrote: > Hi Guennadi, > > On Friday 07 January 2011 15:37:35 Guennadi Liakhovetski wrote: > > On Fri, 7 Jan 2011, Qing Xu wrote: > > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > > special handling in soc-camera core. > > > > Hm, no, guess what? I don't think this can work. The parameter, that this > > routine gets from the user struct v4l2_frmsizeenum contains a member > > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > > them, they deal with mediabus codes. It is the same problem as with old > > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > > either have to add our own .enum_mbus_framesizes video subdevice > > operation, or we abuse this one, but interpret the pixel_format field as a > > media-bus code. > > > > Currently I only see one subdev driver, that implements this API: > > ov7670.c, and it just happily ignores the pixel_format altogether... > > > > Hans, Laurent, what do you think? > > Use the pad-level subdev operations, they take a media bus code as argument > ;-) Sure, but as you will appreciate, a currently mainlinable solution would be preferred. Even if you get MC in next soon enough for 2.6.39, we still will need a while to convert soc-camera to it first. Thanks Guennadi > > > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > > to convert to media-bus code from fourcc. A nit-pick: please, follow the > > style of the file, that you patch and don't add double empty lines between > > functions. > > > > A side question: why do you need this format at all? Is it for some custom > > application? What is your use-case, that makes try_fmt / s_fmt > > insufficient for you and how does enum_framesizes help you? > > -- > Regards, > > Laurent Pinchart > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] v4l: soc-camera: add enum-frame-size ioctl
Hi Guennadi, On Friday 07 January 2011 15:37:35 Guennadi Liakhovetski wrote: > On Fri, 7 Jan 2011, Qing Xu wrote: > > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > > special handling in soc-camera core. > > Hm, no, guess what? I don't think this can work. The parameter, that this > routine gets from the user struct v4l2_frmsizeenum contains a member > pixel_format, which is a fourcc code. Whereas subdevices don't deal with > them, they deal with mediabus codes. It is the same problem as with old > s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we > either have to add our own .enum_mbus_framesizes video subdevice > operation, or we abuse this one, but interpret the pixel_format field as a > media-bus code. > > Currently I only see one subdev driver, that implements this API: > ov7670.c, and it just happily ignores the pixel_format altogether... > > Hans, Laurent, what do you think? Use the pad-level subdev operations, they take a media bus code as argument ;-) > In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() > to convert to media-bus code from fourcc. A nit-pick: please, follow the > style of the file, that you patch and don't add double empty lines between > functions. > > A side question: why do you need this format at all? Is it for some custom > application? What is your use-case, that makes try_fmt / s_fmt > insufficient for you and how does enum_framesizes help you? -- Regards, Laurent Pinchart -- 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] v4l: soc-camera: add enum-frame-size ioctl
On Fri, 7 Jan 2011, Qing Xu wrote: > pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no > special handling in soc-camera core. Hm, no, guess what? I don't think this can work. The parameter, that this routine gets from the user struct v4l2_frmsizeenum contains a member pixel_format, which is a fourcc code. Whereas subdevices don't deal with them, they deal with mediabus codes. It is the same problem as with old s/g/try/enum_fmt, which we replaced with respective mbus variants. So, we either have to add our own .enum_mbus_framesizes video subdevice operation, or we abuse this one, but interpret the pixel_format field as a media-bus code. Currently I only see one subdev driver, that implements this API: ov7670.c, and it just happily ignores the pixel_format altogether... Hans, Laurent, what do you think? In the soc-camera case you will have to use soc_camera_xlate_by_fourcc() to convert to media-bus code from fourcc. A nit-pick: please, follow the style of the file, that you patch and don't add double empty lines between functions. A side question: why do you need this format at all? Is it for some custom application? What is your use-case, that makes try_fmt / s_fmt insufficient for you and how does enum_framesizes help you? Thanks Guennadi > > Signed-off-by: Kassey Lee > Signed-off-by: Qing Xu > --- > drivers/media/video/soc_camera.c | 11 +++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/drivers/media/video/soc_camera.c > b/drivers/media/video/soc_camera.c > index 052bd6d..11715fb 100644 > --- a/drivers/media/video/soc_camera.c > +++ b/drivers/media/video/soc_camera.c > @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void > *priv, v4l2_std_id *a) > return v4l2_subdev_call(sd, core, s_std, *a); > } > > +static int soc_camera_enum_framesizes(struct file *file, void *fh, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct soc_camera_device *icd = file->private_data; > + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); > + > + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); > +} > + > + > static int soc_camera_reqbufs(struct file *file, void *priv, > struct v4l2_requestbuffers *p) > { > @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops > = { > .vidioc_g_input = soc_camera_g_input, > .vidioc_s_input = soc_camera_s_input, > .vidioc_s_std= soc_camera_s_std, > + .vidioc_enum_framesizes = soc_camera_enum_framesizes, > .vidioc_reqbufs = soc_camera_reqbufs, > .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, > .vidioc_querybuf = soc_camera_querybuf, > -- > 1.6.3.3 > --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- 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] [media] v4l: soc-camera: add enum-frame-size ioctl
pass VIDIOC_ENUM_FRAMESIZES down to sub device drivers. So far no special handling in soc-camera core. Signed-off-by: Kassey Lee Signed-off-by: Qing Xu --- drivers/media/video/soc_camera.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6d..11715fb 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -145,6 +145,16 @@ static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) return v4l2_subdev_call(sd, core, s_std, *a); } +static int soc_camera_enum_framesizes(struct file *file, void *fh, +struct v4l2_frmsizeenum *fsize) +{ + struct soc_camera_device *icd = file->private_data; + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + + return v4l2_subdev_call(sd, video, enum_framesizes, fsize); +} + + static int soc_camera_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { @@ -1302,6 +1312,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std= soc_camera_s_std, + .vidioc_enum_framesizes = soc_camera_enum_framesizes, .vidioc_reqbufs = soc_camera_reqbufs, .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, -- 1.6.3.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://vger.kernel.org/majordomo-info.html