Re: [PATCH v6] media: add imx319 camera sensor driver
Hi Bingbu, On Tue, Sep 25, 2018 at 05:10:59PM +0800, Bing Bu Cao wrote: ... > > +/* Initialize control handlers */ > > +static int imx319_init_controls(struct imx319 *imx319) > > +{ > > + struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); > > + struct v4l2_ctrl_handler *ctrl_hdlr; > > + s64 exposure_max; > > + s64 vblank_def; > > + s64 vblank_min; > > + s64 hblank; > > + s64 pixel_rate; > > + const struct imx319_mode *mode; > > + int ret; > > + > > + ctrl_hdlr = &imx319->ctrl_handler; > > + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10); > > + if (ret) > > + return ret; > > + > > + ctrl_hdlr->lock = &imx319->mutex; > > + imx319->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, > > &imx319_ctrl_ops, > > + V4L2_CID_LINK_FREQ, > > 0, 0, > > + > > imx319->hwcfg->link_freqs); > Could you check that the link frequency matches with what the register > lists assume? > >>> Sakari, do you mean associate link frequency index with register list? > > The driver should only allow using link frequencies that are explicitly > > allowed for the system. > Sakari, as current driver only support one link frequency, so I think once > getting the link frequencies from firmware, > driver can simply check and match the values with link_freq_menu_items[0] and > only keep 1 item in the menu: Please wrap the lines at around 76 characters, please. > > max = ARRAY_SIZE(link_freq_menu_items) - 1; > imx319->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx319_ctrl_ops, > V4L2_CID_LINK_FREQ, max, 0, > link_freq_menu_items); > Is it OK? "max" would be 0 in this case, I presume. Seems fine to me. -- Regards, Sakari Ailus sakari.ai...@linux.intel.com
Re: [PATCH v6] media: add imx319 camera sensor driver
On 09/25/2018 03:33 PM, Sakari Ailus wrote: > Hi Bingbu, > > On Tue, Sep 25, 2018 at 02:59:05PM +0800, Bing Bu Cao wrote: >> >> On 09/25/2018 11:57 AM, Bing Bu Cao wrote: >>> On 09/21/2018 08:06 PM, Sakari Ailus wrote: Hi Bingbu, On Fri, Sep 21, 2018 at 05:41:55PM +0800, bingbu@intel.com wrote: > From: Bingbu Cao > > Add a v4l2 sub-device driver for the Sony imx319 image sensor. > This is a camera sensor using the i2c bus for control and the > csi-2 bus for data. > > This driver supports following features: > - manual exposure and analog/digital gain control support > - vblank/hblank control support > - 4 test patterns control support > - vflip/hflip control support (will impact the output bayer order) > - support following resolutions: > - 3264x2448, 3280x2464 @ 30fps > - 1936x1096, 1920x1080 @ 60fps > - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps > - support 4 bayer orders output (via change v/hflip) > - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 > > Cc: Tomasz Figa > Cc: Sakari Ailus > Signed-off-by: Bingbu Cao > Signed-off-by: Tianshu Qiu > > --- > > This patch is based on sakari's media-tree git: > https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 > > Changes from v5: > - add some comments for gain calculation > - use lock to protect the format > > Changes from v4 to v5: > - use single PLL for all internal clocks > - change link frequency to 482.4MHz > - adjust frame timing for 2x2 binning modes >and enlarge frame readout time > - get CSI-2 link frequencies and external clock >from firmware > - use unlocked __v4l2_ctrl_grab() with change from: > > https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab > > Changes since v1: > - fix some coding style issues - line breaks > - add v4l2_ctrl_grab() to prevent v/hflip change >during streaming > - add v4l2 ctrl event (un)subscribe support > - add more info into commit message > > --- > --- > MAINTAINERS|7 + > drivers/media/i2c/Kconfig | 11 + > drivers/media/i2c/Makefile |1 + > drivers/media/i2c/imx319.c | 2545 > > 4 files changed, 2564 insertions(+) > create mode 100644 drivers/media/i2c/imx319.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index a5b256b25905..abc4abb6f83c 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -13530,6 +13530,13 @@ S: Maintained > F: drivers/media/i2c/imx274.c > F: Documentation/devicetree/bindings/media/i2c/imx274.txt > > +SONY IMX319 SENSOR DRIVER > +M: Bingbu Cao > +L: linux-media@vger.kernel.org > +T: git git://linuxtv.org/media_tree.git > +S: Maintained > +F: drivers/media/i2c/imx319.c > + > SONY MEMORYSTICK CARD SUPPORT > M: Alex Dubov > W: http://tifmxx.berlios.de/ > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > index bfdb494686bf..603ac087975b 100644 > --- a/drivers/media/i2c/Kconfig > +++ b/drivers/media/i2c/Kconfig > @@ -614,6 +614,17 @@ config VIDEO_IMX274 > This is a V4L2 sensor driver for the Sony IMX274 > CMOS image sensor. > > +config VIDEO_IMX319 > + tristate "Sony IMX319 sensor support" > + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API > + depends on MEDIA_CAMERA_SUPPORT > + help > + This is a Video4Linux2 sensor driver for the Sony > + IMX319 camera. > + > + To compile this driver as a module, choose M here: the > + module will be called imx319. > + > config VIDEO_OV2640 > tristate "OmniVision OV2640 sensor support" > depends on VIDEO_V4L2 && I2C > diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile > index a94eb03d10d4..d10b438577be 100644 > --- a/drivers/media/i2c/Makefile > +++ b/drivers/media/i2c/Makefile > @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659)+= ov2659.o > obj-$(CONFIG_VIDEO_TC358743) += tc358743.o > obj-$(CONFIG_VIDEO_IMX258) += imx258.o > obj-$(CONFIG_VIDEO_IMX274) += imx274.o > +obj-$(CONFIG_VIDEO_IMX319) += imx319.o > > obj-$(CONFIG_SDR_MAX2175) += max2175.o > diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c > new file mode 100644 > index ..5e80b113c386 > --- /dev/null > +++ b/drivers/media/i2c/imx319.c > @@ -0,0 +1,2545 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (C) 2018 Intel Corporation > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#in
Re: [PATCH v6] media: add imx319 camera sensor driver
Hi Bingbu, On Tue, Sep 25, 2018 at 02:59:05PM +0800, Bing Bu Cao wrote: > > > On 09/25/2018 11:57 AM, Bing Bu Cao wrote: > > > > On 09/21/2018 08:06 PM, Sakari Ailus wrote: > >> Hi Bingbu, > >> > >> On Fri, Sep 21, 2018 at 05:41:55PM +0800, bingbu@intel.com wrote: > >>> From: Bingbu Cao > >>> > >>> Add a v4l2 sub-device driver for the Sony imx319 image sensor. > >>> This is a camera sensor using the i2c bus for control and the > >>> csi-2 bus for data. > >>> > >>> This driver supports following features: > >>> - manual exposure and analog/digital gain control support > >>> - vblank/hblank control support > >>> - 4 test patterns control support > >>> - vflip/hflip control support (will impact the output bayer order) > >>> - support following resolutions: > >>> - 3264x2448, 3280x2464 @ 30fps > >>> - 1936x1096, 1920x1080 @ 60fps > >>> - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps > >>> - support 4 bayer orders output (via change v/hflip) > >>> - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 > >>> > >>> Cc: Tomasz Figa > >>> Cc: Sakari Ailus > >>> Signed-off-by: Bingbu Cao > >>> Signed-off-by: Tianshu Qiu > >>> > >>> --- > >>> > >>> This patch is based on sakari's media-tree git: > >>> https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 > >>> > >>> Changes from v5: > >>> - add some comments for gain calculation > >>> - use lock to protect the format > >>> > >>> Changes from v4 to v5: > >>> - use single PLL for all internal clocks > >>> - change link frequency to 482.4MHz > >>> - adjust frame timing for 2x2 binning modes > >>>and enlarge frame readout time > >>> - get CSI-2 link frequencies and external clock > >>>from firmware > >>> - use unlocked __v4l2_ctrl_grab() with change from: > >>> > >>> https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab > >>> > >>> Changes since v1: > >>> - fix some coding style issues - line breaks > >>> - add v4l2_ctrl_grab() to prevent v/hflip change > >>>during streaming > >>> - add v4l2 ctrl event (un)subscribe support > >>> - add more info into commit message > >>> > >>> --- > >>> --- > >>> MAINTAINERS|7 + > >>> drivers/media/i2c/Kconfig | 11 + > >>> drivers/media/i2c/Makefile |1 + > >>> drivers/media/i2c/imx319.c | 2545 > >>> > >>> 4 files changed, 2564 insertions(+) > >>> create mode 100644 drivers/media/i2c/imx319.c > >>> > >>> diff --git a/MAINTAINERS b/MAINTAINERS > >>> index a5b256b25905..abc4abb6f83c 100644 > >>> --- a/MAINTAINERS > >>> +++ b/MAINTAINERS > >>> @@ -13530,6 +13530,13 @@ S: Maintained > >>> F: drivers/media/i2c/imx274.c > >>> F: Documentation/devicetree/bindings/media/i2c/imx274.txt > >>> > >>> +SONY IMX319 SENSOR DRIVER > >>> +M: Bingbu Cao > >>> +L: linux-media@vger.kernel.org > >>> +T: git git://linuxtv.org/media_tree.git > >>> +S: Maintained > >>> +F: drivers/media/i2c/imx319.c > >>> + > >>> SONY MEMORYSTICK CARD SUPPORT > >>> M: Alex Dubov > >>> W: http://tifmxx.berlios.de/ > >>> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > >>> index bfdb494686bf..603ac087975b 100644 > >>> --- a/drivers/media/i2c/Kconfig > >>> +++ b/drivers/media/i2c/Kconfig > >>> @@ -614,6 +614,17 @@ config VIDEO_IMX274 > >>> This is a V4L2 sensor driver for the Sony IMX274 > >>> CMOS image sensor. > >>> > >>> +config VIDEO_IMX319 > >>> + tristate "Sony IMX319 sensor support" > >>> + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API > >>> + depends on MEDIA_CAMERA_SUPPORT > >>> + help > >>> + This is a Video4Linux2 sensor driver for the Sony > >>> + IMX319 camera. > >>> + > >>> + To compile this driver as a module, choose M here: the > >>> + module will be called imx319. > >>> + > >>> config VIDEO_OV2640 > >>> tristate "OmniVision OV2640 sensor support" > >>> depends on VIDEO_V4L2 && I2C > >>> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile > >>> index a94eb03d10d4..d10b438577be 100644 > >>> --- a/drivers/media/i2c/Makefile > >>> +++ b/drivers/media/i2c/Makefile > >>> @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659)+= ov2659.o > >>> obj-$(CONFIG_VIDEO_TC358743) += tc358743.o > >>> obj-$(CONFIG_VIDEO_IMX258) += imx258.o > >>> obj-$(CONFIG_VIDEO_IMX274) += imx274.o > >>> +obj-$(CONFIG_VIDEO_IMX319) += imx319.o > >>> > >>> obj-$(CONFIG_SDR_MAX2175) += max2175.o > >>> diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c > >>> new file mode 100644 > >>> index ..5e80b113c386 > >>> --- /dev/null > >>> +++ b/drivers/media/i2c/imx319.c > >>> @@ -0,0 +1,2545 @@ > >>> +// SPDX-License-Identifier: GPL-2.0 > >>> +// Copyright (C) 2018 Intel Corporation > >>> + > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> + > >>> +#define
Re: [PATCH v6] media: add imx319 camera sensor driver
On 09/25/2018 11:57 AM, Bing Bu Cao wrote: > > On 09/21/2018 08:06 PM, Sakari Ailus wrote: >> Hi Bingbu, >> >> On Fri, Sep 21, 2018 at 05:41:55PM +0800, bingbu@intel.com wrote: >>> From: Bingbu Cao >>> >>> Add a v4l2 sub-device driver for the Sony imx319 image sensor. >>> This is a camera sensor using the i2c bus for control and the >>> csi-2 bus for data. >>> >>> This driver supports following features: >>> - manual exposure and analog/digital gain control support >>> - vblank/hblank control support >>> - 4 test patterns control support >>> - vflip/hflip control support (will impact the output bayer order) >>> - support following resolutions: >>> - 3264x2448, 3280x2464 @ 30fps >>> - 1936x1096, 1920x1080 @ 60fps >>> - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps >>> - support 4 bayer orders output (via change v/hflip) >>> - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 >>> >>> Cc: Tomasz Figa >>> Cc: Sakari Ailus >>> Signed-off-by: Bingbu Cao >>> Signed-off-by: Tianshu Qiu >>> >>> --- >>> >>> This patch is based on sakari's media-tree git: >>> https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 >>> >>> Changes from v5: >>> - add some comments for gain calculation >>> - use lock to protect the format >>> >>> Changes from v4 to v5: >>> - use single PLL for all internal clocks >>> - change link frequency to 482.4MHz >>> - adjust frame timing for 2x2 binning modes >>>and enlarge frame readout time >>> - get CSI-2 link frequencies and external clock >>>from firmware >>> - use unlocked __v4l2_ctrl_grab() with change from: >>> >>> https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab >>> >>> Changes since v1: >>> - fix some coding style issues - line breaks >>> - add v4l2_ctrl_grab() to prevent v/hflip change >>>during streaming >>> - add v4l2 ctrl event (un)subscribe support >>> - add more info into commit message >>> >>> --- >>> --- >>> MAINTAINERS|7 + >>> drivers/media/i2c/Kconfig | 11 + >>> drivers/media/i2c/Makefile |1 + >>> drivers/media/i2c/imx319.c | 2545 >>> >>> 4 files changed, 2564 insertions(+) >>> create mode 100644 drivers/media/i2c/imx319.c >>> >>> diff --git a/MAINTAINERS b/MAINTAINERS >>> index a5b256b25905..abc4abb6f83c 100644 >>> --- a/MAINTAINERS >>> +++ b/MAINTAINERS >>> @@ -13530,6 +13530,13 @@ S: Maintained >>> F: drivers/media/i2c/imx274.c >>> F: Documentation/devicetree/bindings/media/i2c/imx274.txt >>> >>> +SONY IMX319 SENSOR DRIVER >>> +M: Bingbu Cao >>> +L: linux-media@vger.kernel.org >>> +T: git git://linuxtv.org/media_tree.git >>> +S: Maintained >>> +F: drivers/media/i2c/imx319.c >>> + >>> SONY MEMORYSTICK CARD SUPPORT >>> M: Alex Dubov >>> W: http://tifmxx.berlios.de/ >>> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig >>> index bfdb494686bf..603ac087975b 100644 >>> --- a/drivers/media/i2c/Kconfig >>> +++ b/drivers/media/i2c/Kconfig >>> @@ -614,6 +614,17 @@ config VIDEO_IMX274 >>> This is a V4L2 sensor driver for the Sony IMX274 >>> CMOS image sensor. >>> >>> +config VIDEO_IMX319 >>> + tristate "Sony IMX319 sensor support" >>> + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API >>> + depends on MEDIA_CAMERA_SUPPORT >>> + help >>> + This is a Video4Linux2 sensor driver for the Sony >>> + IMX319 camera. >>> + >>> + To compile this driver as a module, choose M here: the >>> + module will be called imx319. >>> + >>> config VIDEO_OV2640 >>> tristate "OmniVision OV2640 sensor support" >>> depends on VIDEO_V4L2 && I2C >>> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile >>> index a94eb03d10d4..d10b438577be 100644 >>> --- a/drivers/media/i2c/Makefile >>> +++ b/drivers/media/i2c/Makefile >>> @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659) += ov2659.o >>> obj-$(CONFIG_VIDEO_TC358743) += tc358743.o >>> obj-$(CONFIG_VIDEO_IMX258) += imx258.o >>> obj-$(CONFIG_VIDEO_IMX274) += imx274.o >>> +obj-$(CONFIG_VIDEO_IMX319) += imx319.o >>> >>> obj-$(CONFIG_SDR_MAX2175) += max2175.o >>> diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c >>> new file mode 100644 >>> index ..5e80b113c386 >>> --- /dev/null >>> +++ b/drivers/media/i2c/imx319.c >>> @@ -0,0 +1,2545 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +// Copyright (C) 2018 Intel Corporation >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#define IMX319_REG_MODE_SELECT 0x0100 >>> +#define IMX319_MODE_STANDBY0x00 >>> +#define IMX319_MODE_STREAMING 0x01 >>> + >>> +/* Chip ID */ >>> +#define IMX319_REG_CHIP_ID 0x0016 >>> +#define IMX319_CHIP_ID 0x0319 >>> + >>> +/* V_TIMING internal */ >>> +#define IMX319_REG_FLL 0x0340 >>> +#define IMX319_FLL_MAX
Re: [PATCH v6] media: add imx319 camera sensor driver
On 09/21/2018 08:06 PM, Sakari Ailus wrote: > Hi Bingbu, > > On Fri, Sep 21, 2018 at 05:41:55PM +0800, bingbu@intel.com wrote: >> From: Bingbu Cao >> >> Add a v4l2 sub-device driver for the Sony imx319 image sensor. >> This is a camera sensor using the i2c bus for control and the >> csi-2 bus for data. >> >> This driver supports following features: >> - manual exposure and analog/digital gain control support >> - vblank/hblank control support >> - 4 test patterns control support >> - vflip/hflip control support (will impact the output bayer order) >> - support following resolutions: >> - 3264x2448, 3280x2464 @ 30fps >> - 1936x1096, 1920x1080 @ 60fps >> - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps >> - support 4 bayer orders output (via change v/hflip) >> - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 >> >> Cc: Tomasz Figa >> Cc: Sakari Ailus >> Signed-off-by: Bingbu Cao >> Signed-off-by: Tianshu Qiu >> >> --- >> >> This patch is based on sakari's media-tree git: >> https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 >> >> Changes from v5: >> - add some comments for gain calculation >> - use lock to protect the format >> >> Changes from v4 to v5: >> - use single PLL for all internal clocks >> - change link frequency to 482.4MHz >> - adjust frame timing for 2x2 binning modes >>and enlarge frame readout time >> - get CSI-2 link frequencies and external clock >>from firmware >> - use unlocked __v4l2_ctrl_grab() with change from: >>https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab >> >> Changes since v1: >> - fix some coding style issues - line breaks >> - add v4l2_ctrl_grab() to prevent v/hflip change >>during streaming >> - add v4l2 ctrl event (un)subscribe support >> - add more info into commit message >> >> --- >> --- >> MAINTAINERS|7 + >> drivers/media/i2c/Kconfig | 11 + >> drivers/media/i2c/Makefile |1 + >> drivers/media/i2c/imx319.c | 2545 >> >> 4 files changed, 2564 insertions(+) >> create mode 100644 drivers/media/i2c/imx319.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index a5b256b25905..abc4abb6f83c 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -13530,6 +13530,13 @@ S: Maintained >> F: drivers/media/i2c/imx274.c >> F: Documentation/devicetree/bindings/media/i2c/imx274.txt >> >> +SONY IMX319 SENSOR DRIVER >> +M: Bingbu Cao >> +L: linux-media@vger.kernel.org >> +T: git git://linuxtv.org/media_tree.git >> +S: Maintained >> +F: drivers/media/i2c/imx319.c >> + >> SONY MEMORYSTICK CARD SUPPORT >> M: Alex Dubov >> W: http://tifmxx.berlios.de/ >> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig >> index bfdb494686bf..603ac087975b 100644 >> --- a/drivers/media/i2c/Kconfig >> +++ b/drivers/media/i2c/Kconfig >> @@ -614,6 +614,17 @@ config VIDEO_IMX274 >>This is a V4L2 sensor driver for the Sony IMX274 >>CMOS image sensor. >> >> +config VIDEO_IMX319 >> +tristate "Sony IMX319 sensor support" >> +depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API >> +depends on MEDIA_CAMERA_SUPPORT >> +help >> + This is a Video4Linux2 sensor driver for the Sony >> + IMX319 camera. >> + >> + To compile this driver as a module, choose M here: the >> + module will be called imx319. >> + >> config VIDEO_OV2640 >> tristate "OmniVision OV2640 sensor support" >> depends on VIDEO_V4L2 && I2C >> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile >> index a94eb03d10d4..d10b438577be 100644 >> --- a/drivers/media/i2c/Makefile >> +++ b/drivers/media/i2c/Makefile >> @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659) += ov2659.o >> obj-$(CONFIG_VIDEO_TC358743)+= tc358743.o >> obj-$(CONFIG_VIDEO_IMX258) += imx258.o >> obj-$(CONFIG_VIDEO_IMX274) += imx274.o >> +obj-$(CONFIG_VIDEO_IMX319) += imx319.o >> >> obj-$(CONFIG_SDR_MAX2175) += max2175.o >> diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c >> new file mode 100644 >> index ..5e80b113c386 >> --- /dev/null >> +++ b/drivers/media/i2c/imx319.c >> @@ -0,0 +1,2545 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +// Copyright (C) 2018 Intel Corporation >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#define IMX319_REG_MODE_SELECT 0x0100 >> +#define IMX319_MODE_STANDBY 0x00 >> +#define IMX319_MODE_STREAMING 0x01 >> + >> +/* Chip ID */ >> +#define IMX319_REG_CHIP_ID 0x0016 >> +#define IMX319_CHIP_ID 0x0319 >> + >> +/* V_TIMING internal */ >> +#define IMX319_REG_FLL 0x0340 >> +#define IMX319_FLL_MAX 0x >> + >> +/* Exposure control */ >> +#define IMX319_REG_EXPOSURE 0x0202 >> +#define IMX319_EXPOSURE_MIN 1 >> +#define IMX319_EXPOSURE
Re: [PATCH v6] media: add imx319 camera sensor driver
Hi Bingbu, I love your patch! Yet something to improve: [auto build test ERROR on linuxtv-media/master] [also build test ERROR on v4.19-rc4 next-20180921] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/bingbu-cao-intel-com/media-add-imx319-camera-sensor-driver/20180922-115504 base: git://linuxtv.org/media_tree.git master config: openrisc-allmodconfig (attached as .config) compiler: or1k-linux-gcc (GCC) 6.0.0 20160327 (experimental) reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=openrisc All errors (new ones prefixed by >>): drivers/media//i2c/imx319.c: In function 'imx319_set_stream': >> drivers/media//i2c/imx319.c:2153:2: error: implicit declaration of function >> '__v4l2_ctrl_grab' [-Werror=implicit-function-declaration] __v4l2_ctrl_grab(imx319->vflip, enable); ^~~~ cc1: some warnings being treated as errors vim +/__v4l2_ctrl_grab +2153 drivers/media//i2c/imx319.c 2118 2119 static int imx319_set_stream(struct v4l2_subdev *sd, int enable) 2120 { 2121 struct imx319 *imx319 = to_imx319(sd); 2122 struct i2c_client *client = v4l2_get_subdevdata(sd); 2123 int ret = 0; 2124 2125 mutex_lock(&imx319->mutex); 2126 if (imx319->streaming == enable) { 2127 mutex_unlock(&imx319->mutex); 2128 return 0; 2129 } 2130 2131 if (enable) { 2132 ret = pm_runtime_get_sync(&client->dev); 2133 if (ret < 0) { 2134 pm_runtime_put_noidle(&client->dev); 2135 goto err_unlock; 2136 } 2137 2138 /* 2139 * Apply default & customized values 2140 * and then start streaming. 2141 */ 2142 ret = imx319_start_streaming(imx319); 2143 if (ret) 2144 goto err_rpm_put; 2145 } else { 2146 imx319_stop_streaming(imx319); 2147 pm_runtime_put(&client->dev); 2148 } 2149 2150 imx319->streaming = enable; 2151 2152 /* vflip and hflip cannot change during streaming */ > 2153 __v4l2_ctrl_grab(imx319->vflip, enable); 2154 __v4l2_ctrl_grab(imx319->hflip, enable); 2155 2156 mutex_unlock(&imx319->mutex); 2157 2158 return ret; 2159 2160 err_rpm_put: 2161 pm_runtime_put(&client->dev); 2162 err_unlock: 2163 mutex_unlock(&imx319->mutex); 2164 2165 return ret; 2166 } 2167 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v6] media: add imx319 camera sensor driver
Hi Bingbu, On Fri, Sep 21, 2018 at 05:41:55PM +0800, bingbu@intel.com wrote: > From: Bingbu Cao > > Add a v4l2 sub-device driver for the Sony imx319 image sensor. > This is a camera sensor using the i2c bus for control and the > csi-2 bus for data. > > This driver supports following features: > - manual exposure and analog/digital gain control support > - vblank/hblank control support > - 4 test patterns control support > - vflip/hflip control support (will impact the output bayer order) > - support following resolutions: > - 3264x2448, 3280x2464 @ 30fps > - 1936x1096, 1920x1080 @ 60fps > - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps > - support 4 bayer orders output (via change v/hflip) > - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 > > Cc: Tomasz Figa > Cc: Sakari Ailus > Signed-off-by: Bingbu Cao > Signed-off-by: Tianshu Qiu > > --- > > This patch is based on sakari's media-tree git: > https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 > > Changes from v5: > - add some comments for gain calculation > - use lock to protect the format > > Changes from v4 to v5: > - use single PLL for all internal clocks > - change link frequency to 482.4MHz > - adjust frame timing for 2x2 binning modes >and enlarge frame readout time > - get CSI-2 link frequencies and external clock >from firmware > - use unlocked __v4l2_ctrl_grab() with change from: >https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab > > Changes since v1: > - fix some coding style issues - line breaks > - add v4l2_ctrl_grab() to prevent v/hflip change >during streaming > - add v4l2 ctrl event (un)subscribe support > - add more info into commit message > > --- > --- > MAINTAINERS|7 + > drivers/media/i2c/Kconfig | 11 + > drivers/media/i2c/Makefile |1 + > drivers/media/i2c/imx319.c | 2545 > > 4 files changed, 2564 insertions(+) > create mode 100644 drivers/media/i2c/imx319.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index a5b256b25905..abc4abb6f83c 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -13530,6 +13530,13 @@ S: Maintained > F: drivers/media/i2c/imx274.c > F: Documentation/devicetree/bindings/media/i2c/imx274.txt > > +SONY IMX319 SENSOR DRIVER > +M: Bingbu Cao > +L: linux-media@vger.kernel.org > +T: git git://linuxtv.org/media_tree.git > +S: Maintained > +F: drivers/media/i2c/imx319.c > + > SONY MEMORYSTICK CARD SUPPORT > M: Alex Dubov > W: http://tifmxx.berlios.de/ > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > index bfdb494686bf..603ac087975b 100644 > --- a/drivers/media/i2c/Kconfig > +++ b/drivers/media/i2c/Kconfig > @@ -614,6 +614,17 @@ config VIDEO_IMX274 > This is a V4L2 sensor driver for the Sony IMX274 > CMOS image sensor. > > +config VIDEO_IMX319 > + tristate "Sony IMX319 sensor support" > + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API > + depends on MEDIA_CAMERA_SUPPORT > + help > + This is a Video4Linux2 sensor driver for the Sony > + IMX319 camera. > + > + To compile this driver as a module, choose M here: the > + module will be called imx319. > + > config VIDEO_OV2640 > tristate "OmniVision OV2640 sensor support" > depends on VIDEO_V4L2 && I2C > diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile > index a94eb03d10d4..d10b438577be 100644 > --- a/drivers/media/i2c/Makefile > +++ b/drivers/media/i2c/Makefile > @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659)+= ov2659.o > obj-$(CONFIG_VIDEO_TC358743) += tc358743.o > obj-$(CONFIG_VIDEO_IMX258) += imx258.o > obj-$(CONFIG_VIDEO_IMX274) += imx274.o > +obj-$(CONFIG_VIDEO_IMX319) += imx319.o > > obj-$(CONFIG_SDR_MAX2175) += max2175.o > diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c > new file mode 100644 > index ..5e80b113c386 > --- /dev/null > +++ b/drivers/media/i2c/imx319.c > @@ -0,0 +1,2545 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (C) 2018 Intel Corporation > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define IMX319_REG_MODE_SELECT 0x0100 > +#define IMX319_MODE_STANDBY 0x00 > +#define IMX319_MODE_STREAMING0x01 > + > +/* Chip ID */ > +#define IMX319_REG_CHIP_ID 0x0016 > +#define IMX319_CHIP_ID 0x0319 > + > +/* V_TIMING internal */ > +#define IMX319_REG_FLL 0x0340 > +#define IMX319_FLL_MAX 0x > + > +/* Exposure control */ > +#define IMX319_REG_EXPOSURE 0x0202 > +#define IMX319_EXPOSURE_MIN 1 > +#define IMX319_EXPOSURE_STEP 1 > +#define IMX319_EXPOSURE_DEFAULT 0x04f6 > + > +/* > + * the digital control register for all color control looks like: > + * +
[PATCH v6] media: add imx319 camera sensor driver
From: Bingbu Cao Add a v4l2 sub-device driver for the Sony imx319 image sensor. This is a camera sensor using the i2c bus for control and the csi-2 bus for data. This driver supports following features: - manual exposure and analog/digital gain control support - vblank/hblank control support - 4 test patterns control support - vflip/hflip control support (will impact the output bayer order) - support following resolutions: - 3264x2448, 3280x2464 @ 30fps - 1936x1096, 1920x1080 @ 60fps - 1640x1232, 1640x922, 1296x736, 1280x720 @ 120fps - support 4 bayer orders output (via change v/hflip) - SRGGB10(default), SGRBG10, SGBRG10, SBGGR10 Cc: Tomasz Figa Cc: Sakari Ailus Signed-off-by: Bingbu Cao Signed-off-by: Tianshu Qiu --- This patch is based on sakari's media-tree git: https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-4.20-1 Changes from v5: - add some comments for gain calculation - use lock to protect the format Changes from v4 to v5: - use single PLL for all internal clocks - change link frequency to 482.4MHz - adjust frame timing for 2x2 binning modes and enlarge frame readout time - get CSI-2 link frequencies and external clock from firmware - use unlocked __v4l2_ctrl_grab() with change from: https://git.linuxtv.org/sailus/media_tree.git/commit/?h=unlocked-ctrl-grab Changes since v1: - fix some coding style issues - line breaks - add v4l2_ctrl_grab() to prevent v/hflip change during streaming - add v4l2 ctrl event (un)subscribe support - add more info into commit message --- --- MAINTAINERS|7 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile |1 + drivers/media/i2c/imx319.c | 2545 4 files changed, 2564 insertions(+) create mode 100644 drivers/media/i2c/imx319.c diff --git a/MAINTAINERS b/MAINTAINERS index a5b256b25905..abc4abb6f83c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13530,6 +13530,13 @@ S: Maintained F: drivers/media/i2c/imx274.c F: Documentation/devicetree/bindings/media/i2c/imx274.txt +SONY IMX319 SENSOR DRIVER +M: Bingbu Cao +L: linux-media@vger.kernel.org +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: drivers/media/i2c/imx319.c + SONY MEMORYSTICK CARD SUPPORT M: Alex Dubov W: http://tifmxx.berlios.de/ diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index bfdb494686bf..603ac087975b 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -614,6 +614,17 @@ config VIDEO_IMX274 This is a V4L2 sensor driver for the Sony IMX274 CMOS image sensor. +config VIDEO_IMX319 + tristate "Sony IMX319 sensor support" + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + help + This is a Video4Linux2 sensor driver for the Sony + IMX319 camera. + + To compile this driver as a module, choose M here: the + module will be called imx319. + config VIDEO_OV2640 tristate "OmniVision OV2640 sensor support" depends on VIDEO_V4L2 && I2C diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index a94eb03d10d4..d10b438577be 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -108,5 +108,6 @@ obj-$(CONFIG_VIDEO_OV2659) += ov2659.o obj-$(CONFIG_VIDEO_TC358743) += tc358743.o obj-$(CONFIG_VIDEO_IMX258) += imx258.o obj-$(CONFIG_VIDEO_IMX274) += imx274.o +obj-$(CONFIG_VIDEO_IMX319) += imx319.o obj-$(CONFIG_SDR_MAX2175) += max2175.o diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c new file mode 100644 index ..5e80b113c386 --- /dev/null +++ b/drivers/media/i2c/imx319.c @@ -0,0 +1,2545 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Intel Corporation + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IMX319_REG_MODE_SELECT 0x0100 +#define IMX319_MODE_STANDBY0x00 +#define IMX319_MODE_STREAMING 0x01 + +/* Chip ID */ +#define IMX319_REG_CHIP_ID 0x0016 +#define IMX319_CHIP_ID 0x0319 + +/* V_TIMING internal */ +#define IMX319_REG_FLL 0x0340 +#define IMX319_FLL_MAX 0x + +/* Exposure control */ +#define IMX319_REG_EXPOSURE0x0202 +#define IMX319_EXPOSURE_MIN1 +#define IMX319_EXPOSURE_STEP 1 +#define IMX319_EXPOSURE_DEFAULT0x04f6 + +/* + * the digital control register for all color control looks like: + * +-+--+ + * | [7:0] | [15:8] | + * +-+--+ + * |0x020f | 0x020e | + * -- + * it is used to calculate the digital gain times value(integral + fractional) + * the [15:8] bits is the fractional part and [7:0] bits is