Re: [RFC PATCH] media: uvc: *HACK* workaround uvc unregister device
Hi Laurent, this was probably one hack comment to much, so it did not get much attention. :) It is possible that this patch is not fully a workaround. But I am not aware how much this could break along the way. Thanks, Michael On Thu, Oct 02, 2014 at 06:09:47PM +0200, Michael Grzeschik wrote: Currently the uvc_driver is not cleaning up its child devices if a device is still in use. It leads to orphaned devices which are not sitting on any interface. They get cleaned up on uvc_delete which will be called on uvc_remove after the userspace application is closing the stream. When PM_RUNTIME is used in the kernel, this leads to the following backtrace for missing sysfs entries in the orphaned kobjects. This patch is moving the device cleanup code for the child devices from uvc_delete to uvc_unregister_video. It is an *HACK* workaround which is ment to initiate the discussion for a proper solution. This behaviour can simply be reproduced by the following command: $ gst-launch v4l2src device=/dev/video0 ! fakesink - Now disconnect the UVC Camera while the stream is still open and used $ Ctrl-C # to close the running gstreamer pipeline [ 258.012048] [ cut here ] [ 258.021206] WARNING: CPU: 0 PID: 280 at fs/sysfs/group.c:220 sysfs_remove_group+0xb4/0xb8() [ 258.031728] sysfs group 80c79200 not found for kobject 'event0' [ 258.039383] Modules linked in: lock(O) usb_f_ecm g_ether usb_f_rndis u_ether libcomposite coda ath6kl_sdio ath6kl_core [ 258.051098] CPU: 0 PID: 280 Comm: v4l2filter0:src Tainted: G O 3.17.0-rc6-20140925-1+ #10 [ 258.063318] Backtrace: [ 258.066403] [80012ca4] (dump_backtrace) from [80012f94] (show_stack+0x18/0x1c) [ 258.077579] r6:00dc r5:0009 r4:d81f7ba8 r3: [ 258.084549] [80012f7c] (show_stack) from [807872e4] (dump_stack+0x24/0x28) [ 258.091791] [807872c0] (dump_stack) from [80025140] (warn_slowpath_common+0x78/0x90) [ 258.100770] [800250c8] (warn_slowpath_common) from [80025190] (warn_slowpath_fmt+0x38/0x40) [ 258.109818] r8: r7:da00a218 r6:da0520f0 r5: r4:80c79200 [ 258.116675] [8002515c] (warn_slowpath_fmt) from [8015bb4c] (sysfs_remove_group+0xb4/0xb8) [ 258.125824] r3:80c79200 r2:8098e22c [ 258.129463] [8015ba98] (sysfs_remove_group) from [803ec5a4] (dpm_sysfs_remove+0x54/0x58) [ 258.138500] r6:da0520e8 r5:da0520f0 r4:80c79200 [ 258.143195] [803ec550] (dpm_sysfs_remove) from [803e3664] (device_del+0x4c/0x1b0) [ 258.151790] r6:da052004 r5:da0520e8 r4:da052000 r3:da306200 [ 258.157813] [803e3618] (device_del) from [804eb7a8] (evdev_disconnect+0x20/0x48) [ 258.166190] r7:da00a1b4 r6:da052004 r5:da0520e8 r4:da052000 [ 258.172637] [804eb788] (evdev_disconnect) from [804e694c] (__input_unregister_device+0xb0/0x150) [ 258.182282] r6:da00a000 r5:da00a448 r4:da00a434 r3:804eb788 [ 258.188064] [804e689c] (__input_unregister_device) from [804e7b50] (input_unregister_device+0x50/0x78) [ 258.198271] r7:da051c00 r6:da009000 r5:81506254 r4:da00a000 [ 258.204013] [804e7b00] (input_unregister_device) from [8052eba8] (uvc_status_cleanup+0x38/0x3c) [ 258.213557] r4:da009000 r3: [ 258.217221] [8052eb70] (uvc_status_cleanup) from [80524e64] (uvc_delete+0x28/0x140) [ 258.225704] r4:da051c58 r3: [ 258.229322] [80524e3c] (uvc_delete) from [80525098] (uvc_release+0x40/0x44) [ 258.237136] r8: r7:da051c00 r6:da009428 r5:81506254 r4:da051c58 r3:da00951c [ 258.245495] [80525058] (uvc_release) from [80500a0c] (v4l2_device_release+0xd0/0xf4) [ 258.253608] [8050093c] (v4l2_device_release) from [803e30f4] (device_release+0x34/0x98) [ 258.262529] r8:da054070 r7:da026a40 r6:da021c00 r5:da051c58 r4:da051c60 r3:8050093c [ 258.270519] [803e30c0] (device_release) from [80323fd4] (kobject_cleanup+0x98/0x1b8) [ 258.279105] r6:80c78848 r5:da051c60 r4:80cb61e8 r3:803e30c0 [ 258.284887] [80323f3c] (kobject_cleanup) from [80323e6c] (kobject_put+0x50/0x7c) [ 258.292634] r7:da054070 r6:da562258 r5: r4:da051c60 [ 258.298839] [80323e1c] (kobject_put) from [803e350c] (put_device+0x1c/0x20) [ 258.306654] r4:da051c00 [ 258.309221] [803e34f0] (put_device) from [804ff73c] (v4l2_release+0x58/0x7c) [ 258.317133] [804ff6e4] (v4l2_release) from [800f1444] (__fput+0x9c/0x220) [ 258.324554] r5:da15e190 r4:da3c8dc0 [ 258.328171] [800f13a8] (__fput) from [800f1624] (fput+0x10/0x14) [ 258.335344] r10:da306200 r9:da30c620 r8:00418004 r7:da306200 r6:80cc2180 r5:da3ee280 [ 258.343252] r4:da306564 [ 258.346086] [800f1614] (fput) from [8003d198] (task_work_run+0xa0/0xe4) [ 258.353407] [8003d0f8] (task_work_run) from [80025cb8] (do_exit+0x280/0x8d0) [ 258.361489] r7:da30c624 r6:da3c229c r5:da306574 r4:da3c2240 [ 258.367266] [80025a38] (do_exit) from [8002722c] (do_group_exit+0x44/0xb8) [ 258.375011] r7:da30c624 [ 258.377584] [800271e8
[RFC PATCH] media: uvc: *HACK* workaround uvc unregister device *HACK*
Currently the uvc_driver is not cleaning up its child devices if a device is still in use. It leads to orphaned devices which are not sitting on any interface. They get cleaned up on uvc_delete which will be called on uvc_remove after the userspace application is closing the stream. When PM_RUNTIME is used in the kernel, this leads to the following backtrace for missing sysfs entries in the orphaned kobjects. This patch is moving the device cleanup code for the child devices from uvc_delete to uvc_unregister_video. It is an *HACK* workaround which is ment to initiate the discussion for a proper solution. This behaviour can simply be reproduced by the following command: $ gst-launch v4l2src device=/dev/video0 ! fakesink - Now disconnect the UVC Camera while the stream is still open and used $ Ctrl-C # to close the running gstreamer pipeline [ 258.012048] [ cut here ] [ 258.021206] WARNING: CPU: 0 PID: 280 at fs/sysfs/group.c:220 sysfs_remove_group+0xb4/0xb8() [ 258.031728] sysfs group 80c79200 not found for kobject 'event0' [ 258.039383] Modules linked in: lock(O) usb_f_ecm g_ether usb_f_rndis u_ether libcomposite coda ath6kl_sdio ath6kl_core [ 258.051098] CPU: 0 PID: 280 Comm: v4l2filter0:src Tainted: G O 3.17.0-rc6-20140925-1+ #10 [ 258.063318] Backtrace: [ 258.066403] [80012ca4] (dump_backtrace) from [80012f94] (show_stack+0x18/0x1c) [ 258.077579] r6:00dc r5:0009 r4:d81f7ba8 r3: [ 258.084549] [80012f7c] (show_stack) from [807872e4] (dump_stack+0x24/0x28) [ 258.091791] [807872c0] (dump_stack) from [80025140] (warn_slowpath_common+0x78/0x90) [ 258.100770] [800250c8] (warn_slowpath_common) from [80025190] (warn_slowpath_fmt+0x38/0x40) [ 258.109818] r8: r7:da00a218 r6:da0520f0 r5: r4:80c79200 [ 258.116675] [8002515c] (warn_slowpath_fmt) from [8015bb4c] (sysfs_remove_group+0xb4/0xb8) [ 258.125824] r3:80c79200 r2:8098e22c [ 258.129463] [8015ba98] (sysfs_remove_group) from [803ec5a4] (dpm_sysfs_remove+0x54/0x58) [ 258.138500] r6:da0520e8 r5:da0520f0 r4:80c79200 [ 258.143195] [803ec550] (dpm_sysfs_remove) from [803e3664] (device_del+0x4c/0x1b0) [ 258.151790] r6:da052004 r5:da0520e8 r4:da052000 r3:da306200 [ 258.157813] [803e3618] (device_del) from [804eb7a8] (evdev_disconnect+0x20/0x48) [ 258.166190] r7:da00a1b4 r6:da052004 r5:da0520e8 r4:da052000 [ 258.172637] [804eb788] (evdev_disconnect) from [804e694c] (__input_unregister_device+0xb0/0x150) [ 258.182282] r6:da00a000 r5:da00a448 r4:da00a434 r3:804eb788 [ 258.188064] [804e689c] (__input_unregister_device) from [804e7b50] (input_unregister_device+0x50/0x78) [ 258.198271] r7:da051c00 r6:da009000 r5:81506254 r4:da00a000 [ 258.204013] [804e7b00] (input_unregister_device) from [8052eba8] (uvc_status_cleanup+0x38/0x3c) [ 258.213557] r4:da009000 r3: [ 258.217221] [8052eb70] (uvc_status_cleanup) from [80524e64] (uvc_delete+0x28/0x140) [ 258.225704] r4:da051c58 r3: [ 258.229322] [80524e3c] (uvc_delete) from [80525098] (uvc_release+0x40/0x44) [ 258.237136] r8: r7:da051c00 r6:da009428 r5:81506254 r4:da051c58 r3:da00951c [ 258.245495] [80525058] (uvc_release) from [80500a0c] (v4l2_device_release+0xd0/0xf4) [ 258.253608] [8050093c] (v4l2_device_release) from [803e30f4] (device_release+0x34/0x98) [ 258.262529] r8:da054070 r7:da026a40 r6:da021c00 r5:da051c58 r4:da051c60 r3:8050093c [ 258.270519] [803e30c0] (device_release) from [80323fd4] (kobject_cleanup+0x98/0x1b8) [ 258.279105] r6:80c78848 r5:da051c60 r4:80cb61e8 r3:803e30c0 [ 258.284887] [80323f3c] (kobject_cleanup) from [80323e6c] (kobject_put+0x50/0x7c) [ 258.292634] r7:da054070 r6:da562258 r5: r4:da051c60 [ 258.298839] [80323e1c] (kobject_put) from [803e350c] (put_device+0x1c/0x20) [ 258.306654] r4:da051c00 [ 258.309221] [803e34f0] (put_device) from [804ff73c] (v4l2_release+0x58/0x7c) [ 258.317133] [804ff6e4] (v4l2_release) from [800f1444] (__fput+0x9c/0x220) [ 258.324554] r5:da15e190 r4:da3c8dc0 [ 258.328171] [800f13a8] (__fput) from [800f1624] (fput+0x10/0x14) [ 258.335344] r10:da306200 r9:da30c620 r8:00418004 r7:da306200 r6:80cc2180 r5:da3ee280 [ 258.343252] r4:da306564 [ 258.346086] [800f1614] (fput) from [8003d198] (task_work_run+0xa0/0xe4) [ 258.353407] [8003d0f8] (task_work_run) from [80025cb8] (do_exit+0x280/0x8d0) [ 258.361489] r7:da30c624 r6:da3c229c r5:da306574 r4:da3c2240 [ 258.367266] [80025a38] (do_exit) from [8002722c] (do_group_exit+0x44/0xb8) [ 258.375011] r7:da30c624 [ 258.377584] [800271e8] (do_group_exit) from [80031510] (get_signal+0x254/0x6c8) [ 258.385736] r7:da30c624 r6:d81f7ed4 r5:0009 r4:d81f6000 [ 258.391476] [800312bc] (get_signal) from [80012190] (do_signal+0x6c/0x3f4) [ 258.399230] r10: r9:d81f6000 r8:fe00 r7:d81f7ec0 r6:76ca6de6 r5:76ca6de4 [ 258.407190] r4:d81f7fb0 [ 258.409751] [80012124] (do_signal) from [800126c4] (do_work_pending+0xa8/0xe8) [
Re: [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT
Hi Laurent, On Wed, Aug 20, 2014 at 07:05:30PM +0200, Laurent Pinchart wrote: Hi Hans and Michael, On Wednesday 20 August 2014 02:06:54 Hans Verkuil wrote: On 08/19/2014 05:01 PM, Laurent Pinchart wrote: Hi Michael, Thank you for the patch. (CC'ing Hans Verkuil and the linux-media mailing list) On Friday 08 August 2014 17:38:58 Michael Grzeschik wrote: This patch adds ENUM_FMT as possible ioctl to the uvc v4l2 device. That makes userspace applications with a generic IOCTL calling convention make also use of it. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- v1 - v2: - changed first switch case to simple if - added separate function - added description field - bail out on array boundaries drivers/usb/gadget/uvc_v4l2.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c index ad48e81..58633bf 100644 --- a/drivers/usb/gadget/uvc_v4l2.c +++ b/drivers/usb/gadget/uvc_v4l2.c @@ -55,14 +55,30 @@ struct uvc_format { u8 bpp; u32 fcc; +char *description; }; static struct uvc_format uvc_formats[] = { -{ 16, V4L2_PIX_FMT_YUYV }, -{ 0, V4L2_PIX_FMT_MJPEG }, +{ 16, V4L2_PIX_FMT_YUYV, YUV 4:2:2 }, +{ 0, V4L2_PIX_FMT_MJPEG, MJPEG }, Format descriptions are currently duplicated in every driver, causing higher memory usage and different descriptions for the same format depending on the driver. Hans, should we try to fix this ? Yes, we should. It's been on my todo list for ages, but at a very low priority. I'm not planning to work on this in the near future, but if someone else wants to work on this, then just go ahead. Michael, would you like to give this a try, or should I do it ? It seems Philipp is already taking the chance! :) Regards, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 2/2] usb: gadget: f_uvc: Move to video_ioctl2
On Mon, Aug 18, 2014 at 11:16:36PM +0200, Laurent Pinchart wrote: Hi Hans, On Monday 18 August 2014 18:24:26 Hans Verkuil wrote: On 08/18/2014 05:06 PM, Laurent Pinchart wrote: Simplify ioctl handling by using video_ioctl2. Are you able to test this on actual hardware? And if so, can you run v4l2-compliance? I'm afraid not. I don't have a platform with an up and running USB peripheral controller at the moment. You could test it with dummy_hcd gadget on an virtual or non usb machine. Regards, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 v4 4/5] mt9m111: rewrite set_pixfmt
Hi Guennadi, On Sun, Jul 17, 2011 at 07:09:42PM +0200, Guennadi Liakhovetski wrote: On Tue, 12 Jul 2011, Michael Grzeschik wrote: added new bit offset defines, more supported BE colour formats and also support BGR565 swapped pixel formats removed pixfmt helper functions and option flags setting the configuration register directly in set_pixfmt added reg_mask function reg_mask is basically the same as clearing setting registers, but it is more convenient and faster (saves one rw cycle). Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de Signed-off-by: Philipp Wiesner p.wies...@phytec.de Applied after pretty heavy modifications. (1) forward-ported to the current tree, (2) removed Bayer swapping, as discussed earlier, (3) removed double bitfield definitions. Please, check out http://git.linuxtv.org/gliakhovetski/v4l-dvb.git?a=shortlog;h=refs/heads/for-3.1 and see, if I haven't inadvertently broken anything. I double checked all modifications and also tested your patch with some formats. I also prefer the idea to handle the configuration of data_outfmt1 in a separete patch. So everything looks right to me. Thanks, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] mt9m111: move lastpage to struct mt9m111 for multi instances
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- v1 - v2: added initial value -1 for lastpage drivers/media/video/mt9m111.c |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index a357aa8..07af26e 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -184,6 +184,7 @@ struct mt9m111 { struct mutex power_lock; /* lock to protect power_count */ int power_count; const struct mt9m111_datafmt *fmt; + int lastpage; /* PageMap cache value */ unsigned int gain; unsigned char autoexposure; unsigned char datawidth; @@ -202,17 +203,17 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg) { int ret; u16 page; - static int lastpage = -1; /* PageMap cache value */ + struct mt9m111 *mt9m111 = to_mt9m111(client); page = (reg 8); - if (page == lastpage) + if (page == mt9m111-lastpage) return 0; if (page 2) return -EINVAL; ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page)); if (!ret) - lastpage = page; + mt9m111-lastpage = page; return ret; } @@ -932,6 +933,8 @@ static int mt9m111_video_probe(struct soc_camera_device *icd, BUG_ON(!icd-parent || to_soc_camera_host(icd-parent)-nr != icd-iface); + mt9m111-lastpage = -1; + mt9m111-autoexposure = 1; mt9m111-autowhitebalance = 1; -- 1.7.5.4 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/5] mt9m111: fix missing return value check mt9m111_reg_clear
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index f10dcf0..e08b46c 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -248,7 +248,9 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, int ret = 0; ret = mt9m111_reg_read(client, reg); - return mt9m111_reg_write(client, reg, ret ~data); + if (ret = 0) + ret = mt9m111_reg_write(client, reg, ret ~data); + return ret; } static int mt9m111_set_context(struct i2c_client *client, -- 1.7.5.4 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] mt9m111: set inital return values to zero
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 32 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index ebebed9..f10dcf0 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -190,7 +190,7 @@ static struct mt9m111 *to_mt9m111(const struct i2c_client *client) static int reg_page_map_set(struct i2c_client *client, const u16 reg) { - int ret; + int ret = 0; u16 page; static int lastpage = -1; /* PageMap cache value */ @@ -208,7 +208,7 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg) static int mt9m111_reg_read(struct i2c_client *client, const u16 reg) { - int ret; + int ret = 0; ret = reg_page_map_set(client, reg); if (!ret) @@ -221,7 +221,7 @@ static int mt9m111_reg_read(struct i2c_client *client, const u16 reg) static int mt9m111_reg_write(struct i2c_client *client, const u16 reg, const u16 data) { - int ret; + int ret = 0; ret = reg_page_map_set(client, reg); if (!ret) @@ -234,7 +234,7 @@ static int mt9m111_reg_write(struct i2c_client *client, const u16 reg, static int mt9m111_reg_set(struct i2c_client *client, const u16 reg, const u16 data) { - int ret; + int ret = 0; ret = mt9m111_reg_read(client, reg); if (ret = 0) @@ -245,7 +245,7 @@ static int mt9m111_reg_set(struct i2c_client *client, const u16 reg, static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, const u16 data) { - int ret; + int ret = 0; ret = mt9m111_reg_read(client, reg); return mt9m111_reg_write(client, reg, ret ~data); @@ -387,7 +387,7 @@ static int mt9m111_setfmt_yuv(struct i2c_client *client) static int mt9m111_enable(struct i2c_client *client) { struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; ret = reg_set(RESET, MT9M111_RESET_CHIP_ENABLE); if (!ret) @@ -397,7 +397,7 @@ static int mt9m111_enable(struct i2c_client *client) static int mt9m111_reset(struct i2c_client *client) { - int ret; + int ret = 0; ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); if (!ret) @@ -452,7 +452,7 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) struct v4l2_rect rect = a-c; struct i2c_client *client = v4l2_get_subdevdata(sd); struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; dev_dbg(client-dev, %s left=%d, top=%d, width=%d, height=%d\n, __func__, rect.left, rect.top, rect.width, rect.height); @@ -568,7 +568,7 @@ static int mt9m111_s_fmt(struct v4l2_subdev *sd, .width = mf-width, .height = mf-height, }; - int ret; + int ret = 0; fmt = mt9m111_find_datafmt(mf-code, mt9m111_colour_fmts, ARRAY_SIZE(mt9m111_colour_fmts)); @@ -741,7 +741,7 @@ static struct soc_camera_ops mt9m111_ops = { static int mt9m111_set_flip(struct i2c_client *client, int flip, int mask) { struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; if (mt9m111-context == HIGHPOWER) { if (flip) @@ -791,7 +791,7 @@ static int mt9m111_set_global_gain(struct i2c_client *client, int gain) static int mt9m111_set_autoexposure(struct i2c_client *client, int on) { struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; if (on) ret = reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN); @@ -807,7 +807,7 @@ static int mt9m111_set_autoexposure(struct i2c_client *client, int on) static int mt9m111_set_autowhitebalance(struct i2c_client *client, int on) { struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; if (on) ret = reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN); @@ -868,7 +868,7 @@ static int mt9m111_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) struct i2c_client *client = v4l2_get_subdevdata(sd); struct mt9m111 *mt9m111 = to_mt9m111(client); const struct v4l2_queryctrl *qctrl; - int ret; + int ret = 0; qctrl = soc_camera_find_qctrl(mt9m111_ops, ctrl-id); if (!qctrl) @@ -945,7 +945,7 @@ static int mt9m111_resume(struct soc_camera_device *icd) static int mt9m111_init(struct i2c_client *client) { struct mt9m111 *mt9m111 = to_mt9m111(client); - int ret; + int ret = 0; mt9m111-context = HIGHPOWER; ret = mt9m111_enable(client); @@ -969,7 +969,7 @@ static int mt9m111_video_probe(struct soc_camera_device *icd
[PATCH 5/5] mt9m111: make use of testpattern
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- Changes v1 - v2 * removed ifdef DEBUG drivers/media/video/mt9m111.c | 57 + 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 7eb2e4a..a3463d9 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -87,6 +87,7 @@ */ #define MT9M111_OPER_MODE_CTRL 0x106 #define MT9M111_OUTPUT_FORMAT_CTRL 0x108 +#define MT9M111_TEST_PATTERN_GEN 0x148 #define MT9M111_REDUCER_XZOOM_B0x1a0 #define MT9M111_REDUCER_XSIZE_B0x1a1 #define MT9M111_REDUCER_YZOOM_B0x1a3 @@ -103,6 +104,15 @@ #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 1) #define MT9M111_OUTFMT_FLIP_BAYER_COL (1 9) #define MT9M111_OUTFMT_FLIP_BAYER_ROW (1 8) +#define MT9M111_TST_PATT_OFF (0 0) +#define MT9M111_TST_PATT_1 (1 0) +#define MT9M111_TST_PATT_2 (2 0) +#define MT9M111_TST_PATT_3 (3 0) +#define MT9M111_TST_PATT_4 (4 0) +#define MT9M111_TST_PATT_5 (5 0) +#define MT9M111_TST_PATT_6 (6 0) +#define MT9M111_TST_PATT_COLORBARS (7 0) +#define MT9M111_TST_PATT_FORCE_WB_GAIN_1 (1 7) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) @@ -138,6 +148,11 @@ #define MT9M111_MAX_HEIGHT 1024 #define MT9M111_MAX_WIDTH 1280 +static int testpattern; +module_param(testpattern, int, S_IRUGO); +MODULE_PARM_DESC(testpattern, Test pattern: a number from 1 to 10, 0 for + normal usage); + /* MT9M111 has only one fixed colorspace per pixelcode */ struct mt9m111_datafmt { enum v4l2_mbus_pixelcodecode; @@ -464,6 +479,7 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, enum v4l2_mbus_pixelcode code) { u16 data_outfmt1 = 0, data_outfmt2 = 0, mask_outfmt1, mask_outfmt2; + u16 pattern = 0; int ret = 0; switch (code) { @@ -531,6 +547,47 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, if (!ret) ret = reg_mask(OUTPUT_FORMAT_CTRL, data_outfmt1, mask_outfmt1); + switch (testpattern) { + case 1: + pattern = MT9M111_TST_PATT_1 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 2: + pattern = MT9M111_TST_PATT_2 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 3: + pattern = MT9M111_TST_PATT_3 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 4: + pattern = MT9M111_TST_PATT_4 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 5: + pattern = MT9M111_TST_PATT_5 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 6: + pattern = MT9M111_TST_PATT_6 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 7: + pattern = MT9M111_TST_PATT_COLORBARS | + MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 8: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_COL; + break; + case 9: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_ROW; + break; + case 10: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_FRAME; + break; + } + + dev_dbg(client-dev, %s: using testpattern %d\n, __func__, + testpattern); + + if (!ret) + ret = mt9m111_reg_set(client, + MT9M111_TEST_PATTERN_GEN, pattern); + if (!ret) ret = reg_mask(OUTPUT_FORMAT_CTRL2_A, data_outfmt2, mask_outfmt2); -- 1.7.5.4 -- 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 v4 4/5] mt9m111: rewrite set_pixfmt
added new bit offset defines, more supported BE colour formats and also support BGR565 swapped pixel formats removed pixfmt helper functions and option flags setting the configuration register directly in set_pixfmt added reg_mask function reg_mask is basically the same as clearing setting registers, but it is more convenient and faster (saves one rw cycle). Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de Signed-off-by: Philipp Wiesner p.wies...@phytec.de --- Changes v1 - v2 * removed unrelated OPMODE handling in this function Changes v2 - v3 * squashed: [PATCH 04/11] mt9m111: added new bit offset defines * squashed: [PATCH 08/11] mt9m111: added reg_mask function Changes v3 - v4 * removed wrong formats V4L2_MBUS_FMT_{YVYU8,YUYV8}_2X8_BE * fixed some return value handling drivers/media/video/mt9m111.c | 175 ++--- 1 files changed, 77 insertions(+), 98 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 8ad99a9..7eb2e4a 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -63,6 +63,12 @@ #define MT9M111_RESET_RESTART_FRAME(1 1) #define MT9M111_RESET_RESET_MODE (1 0) +#define MT9M111_RM_FULL_POWER_RD (0 10) +#define MT9M111_RM_LOW_POWER_RD(1 10) +#define MT9M111_RM_COL_SKIP_4X (1 5) +#define MT9M111_RM_ROW_SKIP_4X (1 4) +#define MT9M111_RM_COL_SKIP_2X (1 3) +#define MT9M111_RM_ROW_SKIP_2X (1 2) #define MT9M111_RMB_MIRROR_COLS(1 1) #define MT9M111_RMB_MIRROR_ROWS(1 0) #define MT9M111_CTXT_CTRL_RESTART (1 15) @@ -95,7 +101,8 @@ #define MT9M111_OPMODE_AUTOEXPO_EN (1 14) #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 1) - +#define MT9M111_OUTFMT_FLIP_BAYER_COL (1 9) +#define MT9M111_OUTFMT_FLIP_BAYER_ROW (1 8) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) @@ -113,6 +120,7 @@ #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 1) #define MT9M111_OUTFMT_SWAP_RGB_EVEN (1 1) #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr(1 0) +#define MT9M111_OUTFMT_SWAP_RGB_R_B(1 0) /* * Camera control register addresses (0x200..0x2ff not implemented) @@ -122,6 +130,8 @@ #define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val)) #define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val)) #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) +#define reg_mask(reg, val, mask) mt9m111_reg_mask(client, MT9M111_##reg, \ + (val), (mask)) #define MT9M111_MIN_DARK_ROWS 8 #define MT9M111_MIN_DARK_COLS 26 @@ -153,7 +163,11 @@ static const struct mt9m111_datafmt mt9m111_colour_fmts[] = { {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, {V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG}, {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, }; @@ -177,10 +191,6 @@ struct mt9m111 { unsigned int powered:1; unsigned int hflip:1; unsigned int vflip:1; - unsigned int swap_rgb_even_odd:1; - unsigned int swap_rgb_red_blue:1; - unsigned int swap_yuv_y_chromas:1; - unsigned int swap_yuv_cb_cr:1; unsigned int autowhitebalance:1; }; @@ -254,6 +264,17 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, return ret; } +static int mt9m111_reg_mask(struct i2c_client *client, const u16 reg, + const u16 data, const u16 mask) +{ + int ret = 0; + + ret = mt9m111_reg_read(client, reg); + if (ret = 0) + ret = mt9m111_reg_write(client, reg, (ret ~mask) | data); + return ret; +} + static int mt9m111_set_context(struct i2c_client *client, enum mt9m111_context ctxt) { @@ -315,78 +336,6 @@ static int mt9m111_setup_rect(struct i2c_client *client, return ret; } -static int mt9m111_setup_pixfmt(struct i2c_client *client, u16 outfmt) -{ - int ret; - u16 mask = MT9M111_OUTFMT_PROCESSED_BAYER | MT9M111_OUTFMT_RGB | - MT9M111_OUTFMT_BYPASS_IFP | MT9M111_OUTFMT_SWAP_RGB_EVEN | - MT9M111_OUTFMT_RGB565 | MT9M111_OUTFMT_RGB555 | - MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr | - MT9M111_OUTFMT_SWAP_YCbCr_C_Y; - - ret = reg_read(OUTPUT_FORMAT_CTRL2_A); - if (ret = 0) - ret
Re: [PATCH v2 10/11] mt9m111: rewrite set_pixfmt
On Sat, Oct 02, 2010 at 10:03:55AM +0200, Guennadi Liakhovetski wrote: Michael, any insight? long time ago... For the YUV and RGB formats, tested and acked. For the bayer, I don't use it. With row switch, that gives back: byte offset: 0 1 2 3 B G B G G R G R Without the switch: byte offset: 0 1 2 3 G R G R B G B G I would have expected the second version (ie. without the switch, ie. the original version of mt9m111 driver) to be correct, but I might be wrong. Maybe Michael can enlighten me here. Yes this seems odd, i normaly expect the first line to be BGBG. I will search for the cause and reply a little later, perhaps end of the week, since i am also short on time at this moment. I have reviewed the Datasheet of the Camera and found Roberts previously described behaviour as correct. So the Bayercode seems functional in that patch. Ok, _if_ you have to redo this patch, maybe you could also merge [PATCH 04/11] mt9m111: added new bit offset defines [PATCH 08/11] mt9m111: added reg_mask function into it, otherwise their purpose is unclear. I will send a squashed Version of the three patches in some minutes. Cheers, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3] mt9m111: rewrite set_pixfmt
added new bit offset defines, more supported BE colour formats and also support BGR565 swapped pixel formats removed pixfmt helper functions and option flags setting the configuration register directly in set_pixfmt added reg_mask function reg_mask is basically the same as clearing setting registers, but it is more convenient and faster (saves one rw cycle). Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de Signed-off-by: Philipp Wiesner p.wies...@phytec.de --- Changes v1 - v2 * removed unrelated OPMODE handling in this function Changes v2 - v3 * squashed: [PATCH 04/11] mt9m111: added new bit offset defines * squashed: [PATCH 08/11] mt9m111: added reg_mask function drivers/media/video/mt9m111.c | 176 +++-- 1 files changed, 81 insertions(+), 95 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 3eeda19..9da30c0 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -63,6 +63,12 @@ #define MT9M111_RESET_RESTART_FRAME(1 1) #define MT9M111_RESET_RESET_MODE (1 0) +#define MT9M111_RM_FULL_POWER_RD (0 10) +#define MT9M111_RM_LOW_POWER_RD(1 10) +#define MT9M111_RM_COL_SKIP_4X (1 5) +#define MT9M111_RM_ROW_SKIP_4X (1 4) +#define MT9M111_RM_COL_SKIP_2X (1 3) +#define MT9M111_RM_ROW_SKIP_2X (1 2) #define MT9M111_RMB_MIRROR_COLS(1 1) #define MT9M111_RMB_MIRROR_ROWS(1 0) #define MT9M111_CTXT_CTRL_RESTART (1 15) @@ -95,7 +101,8 @@ #define MT9M111_OPMODE_AUTOEXPO_EN (1 14) #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 1) - +#define MT9M111_OUTFMT_FLIP_BAYER_COL (1 9) +#define MT9M111_OUTFMT_FLIP_BAYER_ROW (1 8) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) @@ -113,6 +120,7 @@ #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 1) #define MT9M111_OUTFMT_SWAP_RGB_EVEN (1 1) #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr(1 0) +#define MT9M111_OUTFMT_SWAP_RGB_R_B(1 0) /* * Camera control register addresses (0x200..0x2ff not implemented) @@ -122,6 +130,8 @@ #define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val)) #define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val)) #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) +#define reg_mask(reg, val, mask) mt9m111_reg_mask(client, MT9M111_##reg, \ + (val), (mask)) #define MT9M111_MIN_DARK_ROWS 8 #define MT9M111_MIN_DARK_COLS 26 @@ -148,12 +158,16 @@ static const struct mt9m111_datafmt *mt9m111_find_datafmt( } static const struct mt9m111_datafmt mt9m111_colour_fmts[] = { - {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}, - {V4L2_MBUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG}, - {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}, - {V4L2_MBUS_FMT_VYUY8_2X8, V4L2_COLORSPACE_JPEG}, + {V4L2_MBUS_FMT_YUYV8_2X8_LE, V4L2_COLORSPACE_JPEG}, + {V4L2_MBUS_FMT_YVYU8_2X8_LE, V4L2_COLORSPACE_JPEG}, + {V4L2_MBUS_FMT_YUYV8_2X8_BE, V4L2_COLORSPACE_JPEG}, + {V4L2_MBUS_FMT_YVYU8_2X8_BE, V4L2_COLORSPACE_JPEG}, {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_BGR565_2X8_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_BGR565_2X8_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, }; @@ -176,10 +190,6 @@ struct mt9m111 { unsigned int powered:1; unsigned int hflip:1; unsigned int vflip:1; - unsigned int swap_rgb_even_odd:1; - unsigned int swap_rgb_red_blue:1; - unsigned int swap_yuv_y_chromas:1; - unsigned int swap_yuv_cb_cr:1; unsigned int autowhitebalance:1; }; @@ -251,6 +261,15 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, return mt9m111_reg_write(client, reg, ret ~data); } +static int mt9m111_reg_mask(struct i2c_client *client, const u16 reg, + const u16 data, const u16 mask) +{ + int ret; + + ret = mt9m111_reg_read(client, reg); + return mt9m111_reg_write(client, reg, (ret ~mask) | data); +} + static int mt9m111_set_context(struct i2c_client *client, enum mt9m111_context ctxt) { @@ -312,68 +331,6 @@ static int mt9m111_setup_rect(struct i2c_client *client, return ret; } -static int mt9m111_setup_pixfmt(struct i2c_client *client, u16 outfmt) -{ - int ret; - - ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); - if (!ret) - ret = reg_write
Re: [PATCH v2 10/11] mt9m111: rewrite set_pixfmt
Hi Robert and Guennadi On Sun, Aug 29, 2010 at 09:17:00PM +0200, Robert Jarzmik wrote: Guennadi Liakhovetski g.liakhovet...@gmx.de writes: Robert, I'll need your ack / tested by on this one too. It actually changes behaviour, for example, it sets MT9M111_OUTFMT_FLIP_BAYER_ROW in the OUTPUT_FORMAT_CTRL register for the V4L2_MBUS_FMT_SBGGR8_1X8 8 bit Bayer format. Maybe other things too - please have a look. For the YUV and RGB formats, tested and acked. For the bayer, I don't use it. With row switch, that gives back: byte offset: 0 1 2 3 B G B G G R G R Without the switch: byte offset: 0 1 2 3 G R G R B G B G I would have expected the second version (ie. without the switch, ie. the original version of mt9m111 driver) to be correct, but I might be wrong. Maybe Michael can enlighten me here. Yes this seems odd, i normaly expect the first line to be BGBG. I will search for the cause and reply a little later, perhaps end of the week, since i am also short on time at this moment. Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 v2 00/11] MT9M111/MT9M131
Hi, On Sun, Aug 29, 2010 at 09:20:06PM +0200, Robert Jarzmik wrote: Guennadi Liakhovetski g.liakhovet...@gmx.de writes: On Tue, 17 Aug 2010, Michael Grzeschik wrote: Hi Robert, Guennadi, after the messed up previous patchseries, this v2 series is left without any feedback. Hopefully not forgotten. :-) No, it is not forgotten, please, give me some more time. As you may have noticed, I'm very busy and my reviews are very slow lately. I'm sorry for that, as my work pumps out every bit of energy I have. Perhaps not so bad, but other priorities at the moment here. Except for patch 11 where I'd like a little amendment, I have tested the full serie, and my feeling is that things work at least as well as before, and probably even better. Therefore, as I won't have much time ahead, please find my ack, for the full serie: Acked-by: Robert Jarzmik robert.jarz...@free.fr Anyway, thanks for your time and work so far. Greetings, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 04/11] mt9m111: added new bit offset defines
On Fri, Aug 27, 2010 at 05:11:18PM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de I don't see these being used in any of your patches... Yes, these are not used. They are a left over from the previous patchstack. But they are checked against the datasheet and are correct. Is it a problem to take them anyway? Thanks, Michael --- drivers/media/video/mt9m111.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 8c076e5..1b21522 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -63,6 +63,12 @@ #define MT9M111_RESET_RESTART_FRAME(1 1) #define MT9M111_RESET_RESET_MODE (1 0) +#define MT9M111_RM_FULL_POWER_RD (0 10) +#define MT9M111_RM_LOW_POWER_RD(1 10) +#define MT9M111_RM_COL_SKIP_4X (1 5) +#define MT9M111_RM_ROW_SKIP_4X (1 4) +#define MT9M111_RM_COL_SKIP_2X (1 3) +#define MT9M111_RM_ROW_SKIP_2X (1 2) #define MT9M111_RMB_MIRROR_COLS(1 1) #define MT9M111_RMB_MIRROR_ROWS(1 0) #define MT9M111_CTXT_CTRL_RESTART (1 15) -- 1.7.1 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 04/11] mt9m111: added new bit offset defines
On Fri, Aug 27, 2010 at 06:30:28PM +0200, Guennadi Liakhovetski wrote: On Fri, 27 Aug 2010, Michael Grzeschik wrote: On Fri, Aug 27, 2010 at 05:11:18PM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de I don't see these being used in any of your patches... Yes, these are not used. They are a left over from the previous patchstack. But they are checked against the datasheet and are correct. Is it a problem to take them anyway? It is not a problem, it is unneeded. You do not want to add all registers and all their fields to every driver, do you? There are some drivers in the kernel, that define more registers, than are used. Of course, say, if you use bits 0, 1, 2, and 4 of a register, you might as well define bit 3 - especially, if they are logically related. But this patch adds a whole family of parameters, none of which is used, so, I personally would avoid that. Ok, no big deal. Personally i don't have a problem with additional inexpensive registers and fields. As they often can be a good hint to some functionality of a chip before you begin to scroll through the, sometimes not so easy to find, datasheets. But that is probably a pure matter of taste. Regards, Michael --- drivers/media/video/mt9m111.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 8c076e5..1b21522 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -63,6 +63,12 @@ #define MT9M111_RESET_RESTART_FRAME(1 1) #define MT9M111_RESET_RESET_MODE (1 0) +#define MT9M111_RM_FULL_POWER_RD (0 10) +#define MT9M111_RM_LOW_POWER_RD(1 10) +#define MT9M111_RM_COL_SKIP_4X (1 5) +#define MT9M111_RM_ROW_SKIP_4X (1 4) +#define MT9M111_RM_COL_SKIP_2X (1 3) +#define MT9M111_RM_ROW_SKIP_2X (1 2) #define MT9M111_RMB_MIRROR_COLS(1 1) #define MT9M111_RMB_MIRROR_ROWS(1 0) #define MT9M111_CTXT_CTRL_RESTART (1 15) -- 1.7.1 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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] mx3fb and ipu_idmac cleanups
From: Juergen Beisert j.beis...@pengutronix.de Signed-off-by: Juergen Beisert j...@pengutronix.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/dma/ipu/ipu_idmac.c |2 +- drivers/video/mx3fb.c |6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index cb26ee9..e065703 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c @@ -321,7 +321,7 @@ static void ipu_ch_param_set_size(union chan_param_mem *params, params-ip.wid2 = 4;/* Blue bit width - 1 */ break; case IPU_PIX_FMT_BGR24: - params-ip.bpp = 1;/* 24 BPP RGB PFS */ + params-ip.bpp = 1;/* 24 BPP BGR PFS */ params-ip.pfs = 4; params-ip.npb = 7; params-ip.sat = 2;/* SAT = 32-bit access */ diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c index 7cfc170..658f10a 100644 --- a/drivers/video/mx3fb.c +++ b/drivers/video/mx3fb.c @@ -660,12 +660,12 @@ static uint32_t bpp_to_pixfmt(int bpp) { uint32_t pixfmt = 0; switch (bpp) { - case 24: - pixfmt = IPU_PIX_FMT_BGR24; - break; case 32: pixfmt = IPU_PIX_FMT_BGR32; break; + case 24: + pixfmt = IPU_PIX_FMT_BGR24; + break; case 16: pixfmt = IPU_PIX_FMT_RGB565; break; -- 1.7.1 -- 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 v2 00/11] MT9M111/MT9M131
Hi Robert, Guennadi, after the messed up previous patchseries, this v2 series is left without any feedback. Hopefully not forgotten. :-) Btw: The first two patches are already applied. Thanks, Michael On Tue, Aug 03, 2010 at 12:57:38PM +0200, Michael Grzeschik wrote: Hey everyone, here is v2 of the previous (a little messy) patchseries. After i figured out that the biggest part of the patches were cutted into unrelated and unneeded pieces here hopefully comes a cleaner patchstack. The rest of the patches i send last time is living in my git repo for review, until i figured out that the code is mostly needed for the softcropping feature of the camera. But first things first, here are my changes: Michael Grzeschik (9): mt9m111: init chip after read CHIP_VERSION mt9m111: register cleanup hex to dec bitoffset mt9m111: added new bit offset defines mt9m111: changed MIN_DARK_COLS to MT9M131 spec count mt9m111: cropcap and s_crop check if type is VIDEO_CAPTURE mt9m111: added current colorspace at g_fmt mt9m111: added reg_mask function mt9m111: rewrite set_pixfmt mt9m111: make use of testpattern Philipp Wiesner (1): mt9m111: Added indication that MT9M131 is supported by this driver Sascha Hauer (1): v4l2-mediabus: Add pixelcodes for BGR565 formats drivers/media/video/Kconfig |5 +- drivers/media/video/mt9m111.c | 283 - include/media/v4l2-mediabus.h |2 + 3 files changed, 174 insertions(+), 116 deletions(-) -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] mx2_camera: change to register and probe
Hey Guennadi, On Tue, Aug 10, 2010 at 09:08:11PM +0200, Guennadi Liakhovetski wrote: On Tue, 10 Aug 2010, Michael Grzeschik wrote: Hi Guennadi, On Thu, Aug 05, 2010 at 10:17:11PM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: change this driver back to register and probe, since some platforms first have to initialize an already registered power regulator to switch on the camera. I shall be preparing a pull-request for 2.6.36-rc1 #2, but since we haven't finished discussing this and when this is ready, this will be a fix - without this your platform doesn't work, right? So, we can push it after rc1. The issue is, that we cannot change the platform code from the late_initcall structure. For me there is no other solution than that, because we have to enable the regulator before the camera chip to communicate over i2c. If we would move to the notify way we would first listen for the i2c enabled clients but for that we would still have to first enable the regulator. At this moment i don't see a solution in this way. Hm, I think, there is an easier way to do this: just use the .power() callback from struct soc_camera_link. It is called for the first time before the camera is added to the i2c bus, so, before any IO is taking place. Just be careful to make sure you don't call one-time init actions (like gpio_request()) multiple times - .power is called also later again upon each open / close. So, you'll need some flag to detect the very first power-on. this seems for me to be the best solution so far. At this time i have a patched version (v2) for my pcm970-baseboard.c glue code. I will send it ASOP, so this change back to probe and register patch is not needed anymore. Sorry, for keeping on my attempts to avoid your patch - it really seems to me, a better solution is possible. Good thoughts! Thanks for the hints, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] mx2_camera: remove emma limitation for RGB565
X-Uptime: 16:20:11 up 37 days, 5:31, 61 users, load average: 0.68, 0.32, 0.30 In the current source status the emma has no limitation for any PIXFMT since the data is parsed raw and unprocessed into the memory. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- v1 - v2 Changed Comment in emma_buf_init as recommended drivers/media/video/mx2_camera.c | 15 +-- 1 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index e859c7f..ccd121f 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -712,8 +712,11 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, /* * We only use the EMMA engine to get rid of the broken * DMA Engine. No color space consversion at the moment. -* We adjust incoming and outgoing pixelformat to rgb16 -* and adjust the bytesperline accordingly. +* We set the incomming and outgoing pixelformat to an +* 16 Bit wide format and adjust the bytesperline +* accordingly. With this configuration the inputdata +* will not be changed by the emma and could be any type +* of 16 Bit Pixelformat. */ writel(PRP_CNTL_CH1EN | PRP_CNTL_CSIEN | @@ -897,10 +900,6 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, return -EINVAL; } - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pix-pixelformat != V4L2_PIX_FMT_RGB565) - return -EINVAL; - mf.width= pix-width; mf.height = pix-height; mf.field= pix-field; @@ -944,10 +943,6 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, /* FIXME: implement MX27 limits */ - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pixfmt != V4L2_PIX_FMT_RGB565) - return -EINVAL; - /* limit to MX25 hardware capabilities */ if (cpu_is_mx25()) { if (xlate-host_fmt-bits_per_sample = 8) -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2][RESEND] mx2_camera: remove emma limitation for RGB565
In the current source status the emma has no limitation for any PIXFMT since the data is parsed raw and unprocessed into the memory. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- v1 - v2 Changed Comment in emma_buf_init as recommended drivers/media/video/mx2_camera.c | 15 +-- 1 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index e859c7f..ccd121f 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -712,8 +712,11 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, /* * We only use the EMMA engine to get rid of the broken * DMA Engine. No color space consversion at the moment. -* We adjust incoming and outgoing pixelformat to rgb16 -* and adjust the bytesperline accordingly. +* We set the incomming and outgoing pixelformat to an +* 16 Bit wide format and adjust the bytesperline +* accordingly. With this configuration the inputdata +* will not be changed by the emma and could be any type +* of 16 Bit Pixelformat. */ writel(PRP_CNTL_CH1EN | PRP_CNTL_CSIEN | @@ -897,10 +900,6 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, return -EINVAL; } - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pix-pixelformat != V4L2_PIX_FMT_RGB565) - return -EINVAL; - mf.width= pix-width; mf.height = pix-height; mf.field= pix-field; @@ -944,10 +943,6 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, /* FIXME: implement MX27 limits */ - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pixfmt != V4L2_PIX_FMT_RGB565) - return -EINVAL; - /* limit to MX25 hardware capabilities */ if (cpu_is_mx25()) { if (xlate-host_fmt-bits_per_sample = 8) -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] mx2_camera: change to register and probe
On Wed, Aug 04, 2010 at 10:24:50AM +0200, Guennadi Liakhovetski wrote: On Wed, 4 Aug 2010, Sascha Hauer wrote: On Wed, Aug 04, 2010 at 01:01:34AM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: On Tue, Aug 03, 2010 at 08:22:13PM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: change this driver back to register and probe, since some platforms first have to initialize an already registered power regulator to switch on the camera. Sorry, don't see a difference. Can you give an example of two call sequences, where this change changes the behaviour? Yes, when you look at the today posted patch [1] you find the function pcm970_baseboard_init_late as an late_initcall. It uses an already registred regulator device to turn on the power of the camera before the cameras device registration. [1] [PATCH 1/2] ARM: i.MX27 pcm970: Add camera support http://lists.infradead.org/pipermail/linux-arm-kernel/2010-August/022317.html Sorry again, still don't understand. What I mean is the following: take two cases - before and after your patch. What is the difference? As far as I know, the difference between platform_driver_probe() and platform_driver_register() is just that the probe method gets discarded in an __init section, which is suitable for non hotpluggable devices. I don't know what the difference this should make for call order. So, that's what I am asking about. Can you explain, how this patch changes the call order in your case? Can you tell, that in the unpatches case the probe is called at that moment, and in the patched case it is called at a different point of time and that fixes the problem. The following is above platform_driver_probe: * Use this instead of platform_driver_register() when you know the device * is not hotpluggable and has already been registered, and you want to * remove its run-once probe() infrastructure from memory after the * driver has bound to the device. So platform_driver_probe will only call the probe function when the device is already there when this function runs. This is not the case on our board. We have to register the camera in late_initcall (to make sure the needed regulators are already there). During late_initcall time the platform_driver_probe has already run. Ok, now I see. I missed the key-phrase: before the cameras device registration. Ok, in this case, it's certainly a valid reason for the change. Just one more question: wouldn't calling pcm970_baseboard_init_late() from device_initcall fix the problem without requiring to change the driver? No, sorry but this doesn't solve the problem. I tested it and get an unable to get regulator: -19 when i hit on that. The problem is the device init order. The pcm970_baseboard_init_late comes first and then the regulator. So i think we should keep that patch. Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 2/5] mx2_camera: remove emma limitation for RGB565
On Wed, Aug 04, 2010 at 11:55:39AM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: In the current source status the emma has no limitation for any PIXFMT since the data is parsed raw and unprocessed into the memory. I'd like some explanation for this one too, please. What about + /* + * We only use the EMMA engine to get rid of the broken + * DMA Engine. No color space consversion at the moment. + * We adjust incoming and outgoing pixelformat to rgb16 + * and adjust the bytesperline accordingly. + */ + writel(PRP_CNTL_CH1EN | + PRP_CNTL_CSIEN | + PRP_CNTL_DATA_IN_RGB16 | + PRP_CNTL_CH1_OUT_RGB16 | + PRP_CNTL_CH1_LEN | + PRP_CNTL_CH1BYP | + PRP_CNTL_CH1_TSKIP(0) | + PRP_CNTL_IN_TSKIP(0), + pcdev-base_emma + PRP_CNTL); + + writel(((bytesperline 1) 16) | icd-user_height, + pcdev-base_emma + PRP_SRC_FRAME_SIZE); + writel(((bytesperline 1) 16) | icd-user_height, + pcdev-base_emma + PRP_CH1_OUT_IMAGE_SIZE); + writel(bytesperline, + pcdev-base_emma + PRP_DEST_CH1_LINE_STRIDE); + writel(0x2ca00565, /* RGB565 */ + pcdev-base_emma + PRP_SRC_PIXEL_FORMAT_CNTL); + writel(0x2ca00565, /* RGB565 */ + pcdev-base_emma + PRP_CH1_PIXEL_FORMAT_CNTL); To me it looks like the eMMA is configured for RGB565. What's the trick? Yes, it seems to be an indication, but the emma currently does not touch any pixels, since the SRC_PIXEL_FORMAT and CH1_PIXEL_FORMAT are identical. It will be needed in the future when we are going to do some resizing operations with the emma or the SRC_PIXEL_FORMAT will differ to the output channels. But at that time, the simple condition check for RGB565 wouldn't be enough. So we should better remove them now. Michael Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |8 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index c77a673..ae27640 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -897,10 +897,6 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, return -EINVAL; } - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pix-pixelformat != V4L2_PIX_FMT_RGB565) - return -EINVAL; - mf.width= pix-width; mf.height = pix-height; mf.field= pix-field; @@ -944,10 +940,6 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, /* FIXME: implement MX27 limits */ - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pixfmt != V4L2_PIX_FMT_RGB565) - return -EINVAL; - /* limit to MX25 hardware capabilities */ if (cpu_is_mx25()) { if (xlate-host_fmt-bits_per_sample = 8) -- 1.7.1 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/5] mx2_camera: fix for list bufnum in frame_done_emma
The emma uses bufnum 1 and 0. This patch tells the bufqueue to change the next buffer to the next one and not the current one. Otherwise the BUG_ON above will trigger everytime. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index ae27640..cf9a604 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1193,7 +1193,7 @@ static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev, buf = list_entry(pcdev-capture.next, struct mx2_buffer, vb.queue); - buf-bufnum = bufnum; + buf-bufnum = !bufnum; list_move_tail(pcdev-capture.next, pcdev-active_bufs); -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] mx2_camera: change to register and probe
change this driver back to register and probe, since some platforms first have to initialize an already registered power regulator to switch on the camera. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 98c93fa..c77a673 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1491,13 +1491,15 @@ static struct platform_driver mx2_camera_driver = { .driver = { .name = MX2_CAM_DRV_NAME, }, + + .probe = mx2_camera_probe, .remove = __devexit_p(mx2_camera_remove), }; static int __init mx2_camera_init(void) { - return platform_driver_probe(mx2_camera_driver, mx2_camera_probe); + return platform_driver_register(mx2_camera_driver); } static void __exit mx2_camera_exit(void) -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/5] mx2_camera: add rising edge for pixclock
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index cf9a604..7f27492 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -785,6 +785,8 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd, if (ret 0) return ret; + if (common_flags SOCAM_PCLK_SAMPLE_RISING) + csicr1 |= CSICR1_REDGE; if (common_flags SOCAM_PCLK_SAMPLE_FALLING) csicr1 |= CSICR1_INV_PCLK; if (common_flags SOCAM_VSYNC_ACTIVE_HIGH) -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/5] mx2_camera: remove emma limitation for RGB565
In the current source status the emma has no limitation for any PIXFMT since the data is parsed raw and unprocessed into the memory. Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |8 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index c77a673..ae27640 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -897,10 +897,6 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, return -EINVAL; } - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pix-pixelformat != V4L2_PIX_FMT_RGB565) - return -EINVAL; - mf.width= pix-width; mf.height = pix-height; mf.field= pix-field; @@ -944,10 +940,6 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, /* FIXME: implement MX27 limits */ - /* eMMA can only do RGB565 */ - if (mx27_camera_emma(pcdev) pixfmt != V4L2_PIX_FMT_RGB565) - return -EINVAL; - /* limit to MX25 hardware capabilities */ if (cpu_is_mx25()) { if (xlate-host_fmt-bits_per_sample = 8) -- 1.7.1 -- 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 5/5] mx2_camera: add informative camera clock frequency printout
ported mx27_camera to 2.6.33.2 Signed-off-by: Teresa Gamez t.ga...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mx2_camera.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 7f27492..fb1b1cb 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1360,6 +1360,9 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) goto exit_dma_free; } + dev_info(pdev-dev, Camera clock frequency: %ld\n, + clk_get_rate(pcdev-clk_csi)); + INIT_LIST_HEAD(pcdev-capture); INIT_LIST_HEAD(pcdev-active_bufs); spin_lock_init(pcdev-lock); -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/5] mx2_camera changes and corrections
Hi everybody, this patchseries include little changes, which are necessary for the mx2_camera driver to work properly on i.MX27 baseboards, especially an issue with the emma. Thanks, Michael Michael Grzeschik (5): mx2_camera: change to register and probe mx2_camera: remove emma limitation for RGB565 mx2_camera: fix for list bufnum in frame_done_emma mx2_camera: add rising edge for pixclock mx2_camera: add informative camera clock frequency printout drivers/media/video/mx2_camera.c | 19 +-- 1 files changed, 9 insertions(+), 10 deletions(-) -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 00/11] MT9M111/MT9M131
Hey everyone, here is v2 of the previous (a little messy) patchseries. After i figured out that the biggest part of the patches were cutted into unrelated and unneeded pieces here hopefully comes a cleaner patchstack. The rest of the patches i send last time is living in my git repo for review, until i figured out that the code is mostly needed for the softcropping feature of the camera. But first things first, here are my changes: Michael Grzeschik (9): mt9m111: init chip after read CHIP_VERSION mt9m111: register cleanup hex to dec bitoffset mt9m111: added new bit offset defines mt9m111: changed MIN_DARK_COLS to MT9M131 spec count mt9m111: cropcap and s_crop check if type is VIDEO_CAPTURE mt9m111: added current colorspace at g_fmt mt9m111: added reg_mask function mt9m111: rewrite set_pixfmt mt9m111: make use of testpattern Philipp Wiesner (1): mt9m111: Added indication that MT9M131 is supported by this driver Sascha Hauer (1): v4l2-mediabus: Add pixelcodes for BGR565 formats drivers/media/video/Kconfig |5 +- drivers/media/video/mt9m111.c | 283 - include/media/v4l2-mediabus.h |2 + 3 files changed, 174 insertions(+), 116 deletions(-) -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 05/11] mt9m111: changed MIN_DARK_COLS to MT9M131 spec count
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 1b21522..944e0cb 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -130,7 +130,7 @@ #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) #define MT9M111_MIN_DARK_ROWS 8 -#define MT9M111_MIN_DARK_COLS 24 +#define MT9M111_MIN_DARK_COLS 26 #define MT9M111_MAX_HEIGHT 1024 #define MT9M111_MAX_WIDTH 1280 -- 1.7.1 -- 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 04/11] mt9m111: added new bit offset defines
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 8c076e5..1b21522 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -63,6 +63,12 @@ #define MT9M111_RESET_RESTART_FRAME(1 1) #define MT9M111_RESET_RESET_MODE (1 0) +#define MT9M111_RM_FULL_POWER_RD (0 10) +#define MT9M111_RM_LOW_POWER_RD(1 10) +#define MT9M111_RM_COL_SKIP_4X (1 5) +#define MT9M111_RM_ROW_SKIP_4X (1 4) +#define MT9M111_RM_COL_SKIP_2X (1 3) +#define MT9M111_RM_ROW_SKIP_2X (1 2) #define MT9M111_RMB_MIRROR_COLS(1 1) #define MT9M111_RMB_MIRROR_ROWS(1 0) #define MT9M111_CTXT_CTRL_RESTART (1 15) -- 1.7.1 -- 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 08/11] mt9m111: added reg_mask function
reg_mask is basically the same as clearing setting registers, but it is more convenient and faster (saves one rw cycle). Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 48c63bc..e865938 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -128,6 +128,8 @@ #define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val)) #define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val)) #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) +#define reg_mask(reg, val, mask) mt9m111_reg_mask(client, MT9M111_##reg, \ + (val), (mask)) #define MT9M111_MIN_DARK_ROWS 8 #define MT9M111_MIN_DARK_COLS 26 @@ -257,6 +259,15 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, return mt9m111_reg_write(client, reg, ret ~data); } +static int mt9m111_reg_mask(struct i2c_client *client, const u16 reg, + const u16 data, const u16 mask) +{ + int ret; + + ret = mt9m111_reg_read(client, reg); + return mt9m111_reg_write(client, reg, (ret ~mask) | data); +} + static int mt9m111_set_context(struct i2c_client *client, enum mt9m111_context ctxt) { -- 1.7.1 -- 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 07/11] mt9m111: added current colorspace at g_fmt
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 89c3f89..48c63bc 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -498,6 +498,7 @@ static int mt9m111_g_fmt(struct v4l2_subdev *sd, mf-width = mt9m111-rect.width; mf-height = mt9m111-rect.height; mf-code= mt9m111-fmt-code; + mf-colorspace = mt9m111-fmt-colorspace; mf-field = V4L2_FIELD_NONE; return 0; -- 1.7.1 -- 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 09/11] v4l2-mediabus: Add pixelcodes for BGR565 formats
From: Sascha Hauer s.ha...@pengutronix.de Signed-off-by: Sascha Hauer s.ha...@pengutronix.de --- include/media/v4l2-mediabus.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 0dbe02a..d0b7340 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -32,6 +32,8 @@ enum v4l2_mbus_pixelcode { V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_MBUS_FMT_RGB565_2X8_BE, + V4L2_MBUS_FMT_BGR565_2X8_LE, + V4L2_MBUS_FMT_BGR565_2X8_BE, V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_GREY8_1X8, -- 1.7.1 -- 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 06/11] mt9m111: cropcap and s_crop check if type is VIDEO_CAPTURE
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- This one is a merge of: [PATCH 09/20] mt9m111: cropcap check if type is CAPTURE [PATCH 13/20] mt9m111: s_crop check for VIDEO_CAPTURE type drivers/media/video/mt9m111.c |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 944e0cb..89c3f89 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -453,6 +453,9 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) dev_dbg(client-dev, %s left=%d, top=%d, width=%d, height=%d\n, __func__, rect.left, rect.top, rect.width, rect.height); + if (a-type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + ret = mt9m111_make_rect(client, rect); if (!ret) mt9m111-rect = rect; @@ -472,12 +475,14 @@ static int mt9m111_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) { + if (a-type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + a-bounds.left = MT9M111_MIN_DARK_COLS; a-bounds.top = MT9M111_MIN_DARK_ROWS; a-bounds.width = MT9M111_MAX_WIDTH; a-bounds.height= MT9M111_MAX_HEIGHT; a-defrect = a-bounds; - a-type = V4L2_BUF_TYPE_VIDEO_CAPTURE; a-pixelaspect.numerator= 1; a-pixelaspect.denominator = 1; -- 1.7.1 -- 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 02/11] mt9m111: init chip after read CHIP_VERSION
Moved mt9m111_init after the chip version detection passage: I don't like the idea of writing on a device we haven't identified yet. Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |6 ++ 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 68f3df6..e7618da 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -969,10 +969,6 @@ static int mt9m111_video_probe(struct soc_camera_device *icd, mt9m111-swap_rgb_even_odd = 1; mt9m111-swap_rgb_red_blue = 1; - ret = mt9m111_init(client); - if (ret) - goto ei2c; - data = reg_read(CHIP_VERSION); switch (data) { @@ -993,6 +989,8 @@ static int mt9m111_video_probe(struct soc_camera_device *icd, goto ei2c; } + ret = mt9m111_init(client); + ei2c: return ret; } -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] mx2_camera: change to register and probe
On Tue, Aug 03, 2010 at 08:22:13PM +0200, Guennadi Liakhovetski wrote: On Tue, 3 Aug 2010, Michael Grzeschik wrote: change this driver back to register and probe, since some platforms first have to initialize an already registered power regulator to switch on the camera. Sorry, don't see a difference. Can you give an example of two call sequences, where this change changes the behaviour? Yes, when you look at the today posted patch [1] you find the function pcm970_baseboard_init_late as an late_initcall. It uses an already registred regulator device to turn on the power of the camera before the cameras device registration. [1] [PATCH 1/2] ARM: i.MX27 pcm970: Add camera support http://lists.infradead.org/pipermail/linux-arm-kernel/2010-August/022317.html Thanks, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 00/20] MT9M111/MT9M131
Hey Guennadi, Robert sorry for that lack of information to those patches. I also just have been slicing one big patch into several canonical and tried to get rid of most tofu. You see the result in that patchseries. But since some big changes i could not figure out correctly, i left them in the stack for review. I should have adding an RFC to the Subject on those. Since i still have no response from the original author of these patches and you also see no sense in some changes i will condense the stack to a managable amount and will repost this v2 series in short time. Thanks for your time, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 01/20] mt9m111: Added indication that MT9M131 is supported by this driver
From: Philipp Wiesner p.wies...@phytec.de Added this info to Kconfig and mt9m111.c, some comment cleanup, replaced 'mt9m11x'-statements by clarifications or driver name. Driver is fully compatible to mt9m131 which has only additional functions compared to mt9m111. Those aren't used anyway at the moment. Signed-off-by: Philipp Wiesner p.wies...@phytec.de --- drivers/media/video/Kconfig |5 +++-- drivers/media/video/mt9m111.c | 37 +++-- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index cdbbbe4..0e8cf24 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -871,10 +871,11 @@ config SOC_CAMERA_MT9M001 and colour models. config SOC_CAMERA_MT9M111 - tristate mt9m111 and mt9m112 support + tristate mt9m111, mt9m112 and mt9m131 support depends on SOC_CAMERA I2C help - This driver supports MT9M111 and MT9M112 cameras from Micron + This driver supports MT9M111, MT9M112 and MT9M131 cameras from + Micron/Aptina config SOC_CAMERA_MT9T031 tristate mt9t031 support diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index d35f536..e934559 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -1,5 +1,5 @@ /* - * Driver for MT9M111/MT9M112 CMOS Image Sensor from Micron + * Driver for MT9M111/MT9M112/MT9M131 CMOS Image Sensor from Micron/Aptina * * Copyright (C) 2008, Robert Jarzmik robert.jarz...@free.fr * @@ -19,11 +19,14 @@ #include media/soc_camera.h /* - * mt9m111 and mt9m112 i2c address is 0x5d or 0x48 (depending on SAddr pin) + * MT9M111, MT9M112 and MT9M131: + * i2c address is 0x48 or 0x5d (depending on SADDR pin) * The platform has to define i2c_board_info and call i2c_register_board_info() */ -/* mt9m111: Sensor register addresses */ +/* + * Sensor core register addresses (0x000..0x0ff) + */ #define MT9M111_CHIP_VERSION 0x000 #define MT9M111_ROW_START 0x001 #define MT9M111_COLUMN_START 0x002 @@ -72,8 +75,9 @@ #define MT9M111_CTXT_CTRL_LED_FLASH_EN (1 2) #define MT9M111_CTXT_CTRL_VBLANK_SEL_B (1 1) #define MT9M111_CTXT_CTRL_HBLANK_SEL_B (1 0) + /* - * mt9m111: Colorpipe register addresses (0x100..0x1ff) + * Colorpipe register addresses (0x100..0x1ff) */ #define MT9M111_OPER_MODE_CTRL 0x106 #define MT9M111_OUTPUT_FORMAT_CTRL 0x108 @@ -109,8 +113,9 @@ #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 1) #define MT9M111_OUTFMT_SWAP_RGB_EVEN (1 1) #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr(1 0) + /* - * mt9m111: Camera control register addresses (0x200..0x2ff not implemented) + * Camera control register addresses (0x200..0x2ff not implemented) */ #define reg_read(reg) mt9m111_reg_read(client, MT9M111_##reg) @@ -160,7 +165,8 @@ enum mt9m111_context { struct mt9m111 { struct v4l2_subdev subdev; - int model; /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */ + int model; /* V4L2_IDENT_MT9M111 or V4L2_IDENT_MT9M112 code */ + /* from v4l2-chip-ident.h */ enum mt9m111_context context; struct v4l2_rect rect; const struct mt9m111_datafmt *fmt; @@ -934,7 +940,7 @@ static int mt9m111_init(struct i2c_client *client) if (!ret) ret = mt9m111_set_autoexposure(client, mt9m111-autoexposure); if (ret) - dev_err(client-dev, mt9m11x init failed: %d\n, ret); + dev_err(client-dev, mt9m111 init failed: %d\n, ret); return ret; } @@ -970,21 +976,24 @@ static int mt9m111_video_probe(struct soc_camera_device *icd, data = reg_read(CHIP_VERSION); switch (data) { - case 0x143a: /* MT9M111 */ + case 0x143a: /* MT9M111 or MT9M131 */ mt9m111-model = V4L2_IDENT_MT9M111; + dev_info(client-dev, + Detected a MT9M111/MT9M131 chip ID %x\n, data); break; case 0x148c: /* MT9M112 */ mt9m111-model = V4L2_IDENT_MT9M112; + dev_info(client-dev, Detected a MT9M112 chip ID %x\n, data); break; default: ret = -ENODEV; dev_err(client-dev, - No MT9M11x chip detected, register read %x\n, data); + No MT9M111/MT9M112/MT9M131 chip detected, + register read %x\n, + data); goto ei2c; } - dev_info(client-dev, Detected a MT9M11x chip ID %x\n, data); - ei2c: return ret; } @@ -1034,13 +1043,13 @@ static int mt9m111_probe(struct i2c_client *client, int ret; if (!icd) { - dev_err(client-dev, MT9M11x: missing soc-camera data!\n); + dev_err(client-dev, mt9m111: soc-camera data missing!\n); return
[PATCH 03/20] mt9m111: register cleanup hex to dec bitoffset
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 39dff7c..c72c4b0 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -100,14 +100,14 @@ #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) #define MT9M111_OUTFMT_RGB (1 8) -#define MT9M111_OUTFMT_RGB565 (0x0 6) -#define MT9M111_OUTFMT_RGB555 (0x1 6) -#define MT9M111_OUTFMT_RGB444x (0x2 6) -#define MT9M111_OUTFMT_RGBx444 (0x3 6) -#define MT9M111_OUTFMT_TST_RAMP_OFF(0x0 4) -#define MT9M111_OUTFMT_TST_RAMP_COL(0x1 4) -#define MT9M111_OUTFMT_TST_RAMP_ROW(0x2 4) -#define MT9M111_OUTFMT_TST_RAMP_FRAME (0x3 4) +#define MT9M111_OUTFMT_RGB565 (0 6) +#define MT9M111_OUTFMT_RGB555 (1 6) +#define MT9M111_OUTFMT_RGB444x (2 6) +#define MT9M111_OUTFMT_RGBx444 (3 6) +#define MT9M111_OUTFMT_TST_RAMP_OFF(0 4) +#define MT9M111_OUTFMT_TST_RAMP_COL(1 4) +#define MT9M111_OUTFMT_TST_RAMP_ROW(2 4) +#define MT9M111_OUTFMT_TST_RAMP_FRAME (3 4) #define MT9M111_OUTFMT_SHIFT_3_UP (1 3) #define MT9M111_OUTFMT_AVG_CHROMA (1 2) #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 1) -- 1.7.1 -- 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 00/20] MT9M111/MT9M131
Hi everyone, the following patchseries was created in a rewrite process of the mt9m111 camera driver while it was tested for support of the very similar silicon mt9m121. Some patches add functionality like panning or test pattern generation or adjust rectengular positioning while others do some restructuring. It has been tested as functional. Comments on this are very welcome. Michael Grzeschik (19): mt9m111: init chip after read CHIP_VERSION mt9m111: register cleanup hex to dec bitoffset mt9m111: added new bit offset defines mt9m111: added default row/col/width/height values mt9m111: changed MAX_{HEIGHT,WIDTH} values to silicon pixelcount mt9m111: changed MIN_DARK_COLS to MT9M131 spec count mt9m111: cropcap use defined default rect properties in defrect mt9m111: cropcap check if type is CAPTURE mt9m111: rewrite make_rect for positioning in debug mt9m111: added mt9m111 format structure mt9m111: s_crop add calculation of output size mt9m111: s_crop check for VIDEO_CAPTURE type mt9m111: added reg_mask function mt9m111: rewrite setup_rect, added soft_crop for smooth panning mt9m111: added more supported BE colour formats mt9m111: rewrite set_pixfmt mt9m111: make use of testpattern in debug mode mt9m111: try_fmt rewrite to use preset values mt9m111: s_fmt make use of try_fmt Philipp Wiesner (1): mt9m111: Added indication that MT9M131 is supported by this driver drivers/media/video/Kconfig |5 +- drivers/media/video/mt9m111.c | 596 ++--- 2 files changed, 377 insertions(+), 224 deletions(-) -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 07/20] mt9m111: changed MIN_DARK_COLS to MT9M131 spec count
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 2080615..f024cc5 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -130,7 +130,7 @@ #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) #define MT9M111_MIN_DARK_ROWS 8 -#define MT9M111_MIN_DARK_COLS 24 +#define MT9M111_MIN_DARK_COLS 26 #define MT9M111_MAX_HEIGHT 1032 #define MT9M111_MAX_WIDTH 1288 #define MT9M111_DEF_DARK_ROWS 12 -- 1.7.1 -- 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 08/20] mt9m111: cropcap use defined default rect properties in defrect
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index f024cc5..3b19274 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -480,7 +480,10 @@ static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) a-bounds.top = MT9M111_MIN_DARK_ROWS; a-bounds.width = MT9M111_MAX_WIDTH; a-bounds.height= MT9M111_MAX_HEIGHT; - a-defrect = a-bounds; + a-defrect.left = MT9M111_DEF_DARK_COLS; + a-defrect.top = MT9M111_DEF_DARK_ROWS; + a-defrect.width= MT9M111_DEF_WIDTH; + a-defrect.height = MT9M111_DEF_HEIGHT; a-type = V4L2_BUF_TYPE_VIDEO_CAPTURE; a-pixelaspect.numerator= 1; a-pixelaspect.denominator = 1; -- 1.7.1 -- 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 13/20] mt9m111: s_crop check for VIDEO_CAPTURE type
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 2758a97..4dbaf31 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -478,6 +478,9 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) u32 pixheight = mt9m111-format.mf.height; int ret; + if (a-type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + format.rect = a-c; format.mf = mt9m111-format.mf; -- 1.7.1 -- 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 10/20] mt9m111: rewrite make_rect for positioning in debug
If DEBUG is defined it is possible to set upper left corner Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 31 +++ 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index e8d8e9b..db5ac32 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -428,14 +428,7 @@ static int mt9m111_make_rect(struct i2c_client *client, struct v4l2_rect *rect) { struct mt9m111 *mt9m111 = to_mt9m111(client); - - if (mt9m111-fmt-code == V4L2_MBUS_FMT_SBGGR8_1X8 || - mt9m111-fmt-code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { - /* Bayer format - even size lengths */ - rect-width = ALIGN(rect-width, 2); - rect-height= ALIGN(rect-height, 2); - /* Let the user play with the starting pixel */ - } + enum v4l2_mbus_pixelcode code = mt9m111-fmt-code; /* FIXME: the datasheet doesn't specify minimum sizes */ soc_camera_limit_side(rect-left, rect-width, @@ -444,6 +437,28 @@ static int mt9m111_make_rect(struct i2c_client *client, soc_camera_limit_side(rect-top, rect-height, MT9M111_MIN_DARK_ROWS, 2, MT9M111_MAX_HEIGHT); + switch (code) { + case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE: + /* unprocessed Bayer pattern format, IFP is bypassed */ +#ifndef DEBUG + /* assure that Bayer sequence is BGGR */ + /* in debug mode, let user play with starting pixel */ + rect-left = ALIGN(rect-left, 2); + rect-top = ALIGN(rect-top, 2) + 1; +#endif + case V4L2_MBUS_FMT_SBGGR8_1X8: + /* processed Bayer pattern format, sequence is fixed */ + /* assure even side lengths for both Bayer modes */ + rect-width = ALIGN(rect-width, 2); + rect-height= ALIGN(rect-height, 2); + default: + /* needed to avoid compiler warnings */; + } + + dev_dbg(client-dev, %s: rect: left=%d top=%d width=%d height=%d + mf: pixelcode=%d\n, __func__, rect-left, rect-top, + rect-width, rect-height, code); + return mt9m111_setup_rect(client, rect); } -- 1.7.1 -- 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 20/20] mt9m111: s_fmt make use of try_fmt
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 60 +++-- 1 files changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index f472ca1..ec758ae 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -697,38 +697,6 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, return ret; } -static int mt9m111_s_fmt(struct v4l2_subdev *sd, -struct v4l2_mbus_framefmt *mf) -{ - struct i2c_client *client = sd-priv; - const struct mt9m111_datafmt *fmt; - struct mt9m111 *mt9m111 = to_mt9m111(client); - struct v4l2_rect *rect; - struct mt9m111_format format; - int ret; - - fmt = mt9m111_find_datafmt(mf-code, mt9m111_colour_fmts, - ARRAY_SIZE(mt9m111_colour_fmts)); - if (!fmt) - return -EINVAL; - - format.rect = mt9m111-format.rect; - format.mf = *mf; - rect= format.rect; - - dev_dbg(client-dev, - %s code=%x left=%d, top=%d, width=%d, height=%d\n, __func__, - mf-code, rect-left, rect-top, rect-width, rect-height); - - ret = mt9m111_make_rect(client, format); - if (!ret) - ret = mt9m111_set_pixfmt(client, format.mf.code); - if (!ret) - mt9m111-format = format; - - return ret; -} - static int mt9m111_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { @@ -763,6 +731,34 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd, return 0; } +static int mt9m111_s_fmt(struct v4l2_subdev *sd, +struct v4l2_mbus_framefmt *mf) +{ + struct i2c_client *client = sd-priv; + struct mt9m111 *mt9m111 = to_mt9m111(client); + struct mt9m111_format format; + int ret; + + dev_dbg(client-dev, %s: mf: width=%d height=%d pixelcode=%d + field=%x colorspace=%x\n, __func__, mf-width, mf-height, + mf-code, mf-field, mf-colorspace); + + ret = mt9m111_try_fmt(sd, mf); + + if (!ret) { + format.rect = mt9m111-format.rect; + format.mf = *mf; + + ret = mt9m111_make_rect(client, format); + } + if (!ret) + ret = mt9m111_set_pixfmt(client, format.mf.code); + if (!ret) + mt9m111-format = format; + + return ret; +} + static int mt9m111_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id) { -- 1.7.1 -- 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 14/20] mt9m111: added reg_mask function
reg_mask is basically the same as clearing setting registers, but it is more convenient and faster (saves one rw cycle). Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 4dbaf31..161c751 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -128,6 +128,8 @@ #define reg_write(reg, val) mt9m111_reg_write(client, MT9M111_##reg, (val)) #define reg_set(reg, val) mt9m111_reg_set(client, MT9M111_##reg, (val)) #define reg_clear(reg, val) mt9m111_reg_clear(client, MT9M111_##reg, (val)) +#define reg_mask(reg, val, mask) mt9m111_reg_mask(client, MT9M111_##reg, \ + (val), (mask)) #define MT9M111_MIN_DARK_ROWS 8 #define MT9M111_MIN_DARK_COLS 26 @@ -265,6 +267,15 @@ static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg, return mt9m111_reg_write(client, reg, ret ~data); } +static int mt9m111_reg_mask(struct i2c_client *client, const u16 reg, + const u16 data, const u16 mask) +{ + int ret; + + ret = mt9m111_reg_read(client, reg); + return mt9m111_reg_write(client, reg, (ret ~mask) | data); +} + static int mt9m111_set_context(struct i2c_client *client, enum mt9m111_context ctxt) { -- 1.7.1 -- 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 16/20] mt9m111: added more supported BE colour formats
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 11a68b6..6da9f48 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -175,7 +175,9 @@ static const struct mt9m111_datafmt mt9m111_colour_fmts[] = { {V4L2_MBUS_FMT_YUYV8_2X8_BE, V4L2_COLORSPACE_JPEG}, {V4L2_MBUS_FMT_YVYU8_2X8_BE, V4L2_COLORSPACE_JPEG}, {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB}, + {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB}, {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB}, }; -- 1.7.1 -- 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 15/20] mt9m111: rewrite setup_rect, added soft_crop for smooth panning
-soft_crop: enables the use of the sensors cropping abilities instead of using real roi. This is needed to make use of the 'pan' registers for smooth panning. Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 106 +++- 1 files changed, 82 insertions(+), 24 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 161c751..11a68b6 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -87,12 +87,16 @@ */ #define MT9M111_OPER_MODE_CTRL 0x106 #define MT9M111_OUTPUT_FORMAT_CTRL 0x108 +#define MT9M111_REDUCER_XPAN_B 0x19f #define MT9M111_REDUCER_XZOOM_B0x1a0 #define MT9M111_REDUCER_XSIZE_B0x1a1 +#define MT9M111_REDUCER_YPAN_B 0x1a2 #define MT9M111_REDUCER_YZOOM_B0x1a3 #define MT9M111_REDUCER_YSIZE_B0x1a4 +#define MT9M111_REDUCER_XPAN_A 0x1a5 #define MT9M111_REDUCER_XZOOM_A0x1a6 #define MT9M111_REDUCER_XSIZE_A0x1a7 +#define MT9M111_REDUCER_YPAN_A 0x1a8 #define MT9M111_REDUCER_YZOOM_A0x1a9 #define MT9M111_REDUCER_YSIZE_A0x1aa @@ -101,7 +105,8 @@ #define MT9M111_OPMODE_AUTOEXPO_EN (1 14) #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 1) - +#define MT9M111_OUTFMT_CFA_1ST_ROW_BLUE(1 1) +#define MT9M111_OUTFMT_CFA_1ST_COL_R_B (1 0) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) @@ -140,6 +145,11 @@ #define MT9M111_DEF_HEIGHT 1024 #define MT9M111_DEF_WIDTH 1280 +static int soft_crop; +module_param(soft_crop, int, S_IRUGO); +MODULE_PARM_DESC(soft_crop, Enables soft-cropping and thus the use of + pan register); + /* MT9M111 has only one fixed colorspace per pixelcode */ struct mt9m111_datafmt { enum v4l2_mbus_pixelcodecode; @@ -296,42 +306,90 @@ static int mt9m111_setup_rect(struct i2c_client *client, struct mt9m111_format *format) { struct v4l2_rect *rect = format-rect; - int ret, is_raw_format; - int width = rect-width; - int height = rect-height; - - if (format-mf.code == V4L2_MBUS_FMT_SBGGR8_1X8 || - format-mf.code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) - is_raw_format = 1; - else - is_raw_format = 0; + struct v4l2_mbus_framefmt *mf = format-mf; + enum v4l2_mbus_pixelcode *code = format-mf.code; + u16 data_outfmt1 = 0, mask_outfmt1; + u16 colum_start, row_start, window_width, window_height, xpan, ypan; + int ret; - ret = reg_write(COLUMN_START, rect-left); - if (!ret) - ret = reg_write(ROW_START, rect-top); + dev_dbg(client-dev, %s: rect: left=%d top=%d width=%d height=%d + mf: pixelcode=%d\n, __func__, rect-left, rect-top, + rect-width, rect-height, *code); - if (is_raw_format) { + if (*code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { + ret = reg_write(COLUMN_START, rect-left); if (!ret) - ret = reg_write(WINDOW_WIDTH, width); + ret = reg_write(ROW_START, rect-top); if (!ret) - ret = reg_write(WINDOW_HEIGHT, height); + ret = reg_write(WINDOW_WIDTH, rect-width); + if (!ret) + ret = reg_write(WINDOW_HEIGHT, rect-height); } else { + if (soft_crop) { + /* use 'soft cropping' through ZOOM and PAN registers */ + /* enables use of smart zooming and panning functions */ + colum_start = MT9M111_MIN_DARK_COLS; + row_start = MT9M111_MIN_DARK_ROWS; + window_width= MT9M111_MAX_WIDTH; + window_height = MT9M111_MAX_HEIGHT; + xpan= rect-left - MT9M111_MIN_DARK_COLS; + ypan= rect-top - MT9M111_MIN_DARK_ROWS; + } else { + /* use real cropping, smaller roi increases framerate */ + colum_start = rect-left; + row_start = rect-top; + window_width= rect-width; + window_height = rect-height; + xpan= 0; + ypan= 0; + } + + ret = reg_write(COLUMN_START, colum_start); + if (!ret) + ret = reg_write(ROW_START, row_start); if (!ret) - ret = reg_write(REDUCER_XZOOM_B, MT9M111_MAX_WIDTH
[PATCH 17/20] mt9m111: rewrite set_pixfmt
removed pixfmt helper functions and option flags setting the configuration register directly in set_pixfmt Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 142 - 1 files changed, 56 insertions(+), 86 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 6da9f48..f327177 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -104,7 +104,10 @@ #define MT9M111_OUTPUT_FORMAT_CTRL2_B 0x19b #define MT9M111_OPMODE_AUTOEXPO_EN (1 14) +#define MT9M111_OPMODE_FLICKER_DET_EN (1 7) #define MT9M111_OPMODE_AUTOWHITEBAL_EN (1 1) +#define MT9M111_OUTFMT_FLIP_BAYER_COL (1 9) +#define MT9M111_OUTFMT_FLIP_BAYER_ROW (1 8) #define MT9M111_OUTFMT_CFA_1ST_ROW_BLUE(1 1) #define MT9M111_OUTFMT_CFA_1ST_COL_R_B (1 0) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) @@ -124,6 +127,7 @@ #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y (1 1) #define MT9M111_OUTFMT_SWAP_RGB_EVEN (1 1) #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr(1 0) +#define MT9M111_OUTFMT_SWAP_RGB_R_B(1 0) /* * Camera control register addresses (0x200..0x2ff not implemented) @@ -204,10 +208,6 @@ struct mt9m111 { unsigned int powered:1; unsigned int hflip:1; unsigned int vflip:1; - unsigned int swap_rgb_even_odd:1; - unsigned int swap_rgb_red_blue:1; - unsigned int swap_yuv_y_chromas:1; - unsigned int swap_yuv_cb_cr:1; unsigned int autowhitebalance:1; }; @@ -397,68 +397,6 @@ static int mt9m111_setup_rect(struct i2c_client *client, return ret; } -static int mt9m111_setup_pixfmt(struct i2c_client *client, u16 outfmt) -{ - int ret; - - ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); - if (!ret) - ret = reg_write(OUTPUT_FORMAT_CTRL2_B, outfmt); - return ret; -} - -static int mt9m111_setfmt_bayer8(struct i2c_client *client) -{ - return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_PROCESSED_BAYER | - MT9M111_OUTFMT_RGB); -} - -static int mt9m111_setfmt_bayer10(struct i2c_client *client) -{ - return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_BYPASS_IFP); -} - -static int mt9m111_setfmt_rgb565(struct i2c_client *client) -{ - struct mt9m111 *mt9m111 = to_mt9m111(client); - int val = 0; - - if (mt9m111-swap_rgb_red_blue) - val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr; - if (mt9m111-swap_rgb_even_odd) - val |= MT9M111_OUTFMT_SWAP_RGB_EVEN; - val |= MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB565; - - return mt9m111_setup_pixfmt(client, val); -} - -static int mt9m111_setfmt_rgb555(struct i2c_client *client) -{ - struct mt9m111 *mt9m111 = to_mt9m111(client); - int val = 0; - - if (mt9m111-swap_rgb_red_blue) - val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr; - if (mt9m111-swap_rgb_even_odd) - val |= MT9M111_OUTFMT_SWAP_RGB_EVEN; - val |= MT9M111_OUTFMT_RGB | MT9M111_OUTFMT_RGB555; - - return mt9m111_setup_pixfmt(client, val); -} - -static int mt9m111_setfmt_yuv(struct i2c_client *client) -{ - struct mt9m111 *mt9m111 = to_mt9m111(client); - int val = 0; - - if (mt9m111-swap_yuv_cb_cr) - val |= MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr; - if (mt9m111-swap_yuv_y_chromas) - val |= MT9M111_OUTFMT_SWAP_YCbCr_C_Y; - - return mt9m111_setup_pixfmt(client, val); -} - static int mt9m111_enable(struct i2c_client *client) { struct mt9m111 *mt9m111 = to_mt9m111(client); @@ -616,41 +554,49 @@ static int mt9m111_g_fmt(struct v4l2_subdev *sd, static int mt9m111_set_pixfmt(struct i2c_client *client, enum v4l2_mbus_pixelcode code) { - struct mt9m111 *mt9m111 = to_mt9m111(client); + u16 data_outfmt1 = 0, data_outfmt2 = 0, mask_outfmt1, mask_outfmt2; + u16 data_opermod; int ret; + data_opermod = MT9M111_OPMODE_AUTOEXPO_EN | + MT9M111_OPMODE_FLICKER_DET_EN | MT9M111_OPMODE_AUTOWHITEBAL_EN; + switch (code) { case V4L2_MBUS_FMT_SBGGR8_1X8: - ret = mt9m111_setfmt_bayer8(client); + data_outfmt1 = MT9M111_OUTFMT_FLIP_BAYER_ROW; + data_outfmt2 = MT9M111_OUTFMT_PROCESSED_BAYER | + MT9M111_OUTFMT_RGB; break; case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE: - ret = mt9m111_setfmt_bayer10(client); + data_outfmt2 = MT9M111_OUTFMT_BYPASS_IFP | MT9M111_OUTFMT_RGB; break; case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: - ret = mt9m111_setfmt_rgb555(client); + data_outfmt2 = MT9M111_OUTFMT_SWAP_RGB_EVEN | + MT9M111_OUTFMT_RGB | + MT9M111_OUTFMT_RGB555
[PATCH 19/20] mt9m111: try_fmt rewrite to use preset values
make use of the format.rect boundery values Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 41 +++-- 1 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 799a735..f472ca1 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -733,35 +733,32 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = sd-priv; + struct mt9m111 *mt9m111 = to_mt9m111(client); + struct v4l2_rect rect = mt9m111-format.rect; const struct mt9m111_datafmt *fmt; - bool bayer = mf-code == V4L2_MBUS_FMT_SBGGR8_1X8 || - mf-code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE; fmt = mt9m111_find_datafmt(mf-code, mt9m111_colour_fmts, ARRAY_SIZE(mt9m111_colour_fmts)); if (!fmt) return -EINVAL; - /* -* With Bayer format enforce even side lengths, but let the user play -* with the starting pixel -*/ + mf-code= fmt-code; + mf-colorspace = fmt-colorspace; + mf-field = V4L2_FIELD_NONE; - if (mf-height MT9M111_MAX_HEIGHT) - mf-height = MT9M111_MAX_HEIGHT; - else if (mf-height 2) - mf-height = 2; - else if (bayer) - mf-height = ALIGN(mf-height, 2); - - if (mf-width MT9M111_MAX_WIDTH) - mf-width = MT9M111_MAX_WIDTH; - else if (mf-width 2) - mf-width = 2; - else if (bayer) - mf-width = ALIGN(mf-width, 2); - - mf-colorspace = fmt-colorspace; + if (mf-code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) { + mf-width = rect.width; + mf-height = rect.height; + } else { + if (mf-width rect.width) + mf-width = rect.width; + if (mf-height rect.height) + mf-height = rect.height; + } + + dev_dbg(client-dev, %s: mf: width=%d height=%d pixelcode=%d + field=%x colorspace=%x\n, __func__, mf-width, mf-height, + mf-code, mf-field, mf-colorspace); return 0; } -- 1.7.1 -- 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 18/20] mt9m111: make use of testpattern in debug mode
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c | 63 + 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index f327177..799a735 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -87,6 +87,7 @@ */ #define MT9M111_OPER_MODE_CTRL 0x106 #define MT9M111_OUTPUT_FORMAT_CTRL 0x108 +#define MT9M111_TEST_PATTERN_GEN 0x148 #define MT9M111_REDUCER_XPAN_B 0x19f #define MT9M111_REDUCER_XZOOM_B0x1a0 #define MT9M111_REDUCER_XSIZE_B0x1a1 @@ -110,6 +111,15 @@ #define MT9M111_OUTFMT_FLIP_BAYER_ROW (1 8) #define MT9M111_OUTFMT_CFA_1ST_ROW_BLUE(1 1) #define MT9M111_OUTFMT_CFA_1ST_COL_R_B (1 0) +#define MT9M111_TST_PATT_OFF (0 0) +#define MT9M111_TST_PATT_1 (1 0) +#define MT9M111_TST_PATT_2 (2 0) +#define MT9M111_TST_PATT_3 (3 0) +#define MT9M111_TST_PATT_4 (4 0) +#define MT9M111_TST_PATT_5 (5 0) +#define MT9M111_TST_PATT_6 (6 0) +#define MT9M111_TST_PATT_COLORBARS (7 0) +#define MT9M111_TST_PATT_FORCE_WB_GAIN_1 (1 7) #define MT9M111_OUTFMT_PROCESSED_BAYER (1 14) #define MT9M111_OUTFMT_BYPASS_IFP (1 10) #define MT9M111_OUTFMT_INV_PIX_CLOCK (1 9) @@ -149,6 +159,13 @@ #define MT9M111_DEF_HEIGHT 1024 #define MT9M111_DEF_WIDTH 1280 +#ifdef DEBUG +static int testpattern; +module_param(testpattern, int, S_IRUGO); +MODULE_PARM_DESC(testpattern, Test pattern: a number from 1 to 10, 0 for + normal usage); +#endif + static int soft_crop; module_param(soft_crop, int, S_IRUGO); MODULE_PARM_DESC(soft_crop, Enables soft-cropping and thus the use of @@ -556,6 +573,9 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, { u16 data_outfmt1 = 0, data_outfmt2 = 0, mask_outfmt1, mask_outfmt2; u16 data_opermod; +#ifdef DEBUG + u16 pattern = 0; +#endif int ret; data_opermod = MT9M111_OPMODE_AUTOEXPO_EN | @@ -616,6 +636,49 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, ret = reg_mask(OUTPUT_FORMAT_CTRL, data_outfmt1, mask_outfmt1); +#ifdef DEBUG + switch (testpattern) { + case 1: + pattern = MT9M111_TST_PATT_1 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 2: + pattern = MT9M111_TST_PATT_2 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 3: + pattern = MT9M111_TST_PATT_3 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 4: + pattern = MT9M111_TST_PATT_4 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 5: + pattern = MT9M111_TST_PATT_5 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 6: + pattern = MT9M111_TST_PATT_6 | MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 7: + pattern = MT9M111_TST_PATT_COLORBARS | + MT9M111_TST_PATT_FORCE_WB_GAIN_1; + break; + case 8: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_COL; + break; + case 9: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_ROW; + break; + case 10: + data_outfmt2 |= MT9M111_OUTFMT_TST_RAMP_FRAME; + break; + } + + dev_dbg(client-dev, %s: using testpattern %d\n, __func__, + testpattern); + + if (!ret) + ret = mt9m111_reg_set(client, + MT9M111_TEST_PATTERN_GEN, pattern); +#endif + if (!ret) ret = reg_mask(OUTPUT_FORMAT_CTRL2_A, data_outfmt2, mask_outfmt2); -- 1.7.1 -- 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 05/20] mt9m111: added default row/col/width/height values
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index aeb2241..5f0c55e 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -133,6 +133,10 @@ #define MT9M111_MIN_DARK_COLS 24 #define MT9M111_MAX_HEIGHT 1024 #define MT9M111_MAX_WIDTH 1280 +#define MT9M111_DEF_DARK_ROWS 12 +#define MT9M111_DEF_DARK_COLS 30 +#define MT9M111_DEF_HEIGHT 1024 +#define MT9M111_DEF_WIDTH 1280 /* MT9M111 has only one fixed colorspace per pixelcode */ struct mt9m111_datafmt { -- 1.7.1 -- 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 06/20] mt9m111: changed MAX_{HEIGHT,WIDTH} values to silicon pixelcount
Signed-off-by: Philipp Wiesner p.wies...@phytec.de Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de --- drivers/media/video/mt9m111.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 5f0c55e..2080615 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c @@ -131,8 +131,8 @@ #define MT9M111_MIN_DARK_ROWS 8 #define MT9M111_MIN_DARK_COLS 24 -#define MT9M111_MAX_HEIGHT 1024 -#define MT9M111_MAX_WIDTH 1280 +#define MT9M111_MAX_HEIGHT 1032 +#define MT9M111_MAX_WIDTH 1288 #define MT9M111_DEF_DARK_ROWS 12 #define MT9M111_DEF_DARK_COLS 30 #define MT9M111_DEF_HEIGHT 1024 -- 1.7.1 -- 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