Message ID | 20221125153120.541298-6-petko.manolov@konsulko.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Adds media driver for Sony IMX492 sensor | expand |
Hi Petko, I love your patch! Perhaps something to improve: [auto build test WARNING on media-tree/master] [also build test WARNING on sailus-media-tree/streams linus/master v6.1-rc6 next-20221125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Petko-Manolov/Adds-media-driver-for-Sony-IMX492-sensor/20221125-233206 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20221125153120.541298-6-petko.manolov%40konsulko.com patch subject: [PATCH v1 5/5] media: i2c: add imx492 entry for make config: sh-allmodconfig compiler: sh4-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/18ef413f6501ce8e80e9b8d4b141a32eb5efb610 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Petko-Manolov/Adds-media-driver-for-Sony-IMX492-sensor/20221125-233206 git checkout 18ef413f6501ce8e80e9b8d4b141a32eb5efb610 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/media/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/media/i2c/imx492.c: In function 'imx492_update_exp_gain': >> drivers/media/i2c/imx492.c:363:19: warning: variable 'shutter' set but not used [-Wunused-but-set-variable] 363 | u32 lpfr, shutter; | ^~~~~~~ -- drivers/media/i2c/imx492.c:115: warning: Function parameter or member 'hblank_min' not described in 'imx492_mode' drivers/media/i2c/imx492.c:115: warning: Function parameter or member 'hblank_max' not described in 'imx492_mode' drivers/media/i2c/imx492.c:161: warning: Function parameter or member 'scap' not described in 'imx492' drivers/media/i2c/imx492.c:161: warning: Function parameter or member 'power_gpio' not described in 'imx492' drivers/media/i2c/imx492.c:161: warning: Function parameter or member 'oscen_gpio' not described in 'imx492' drivers/media/i2c/imx492.c:161: warning: Function parameter or member 'tpatt' not described in 'imx492' >> drivers/media/i2c/imx492.c:481: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst n * imx492_fill_pad_format() - Fill subdevice pad format Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for COMMON_CLK Depends on [n]: !HAVE_LEGACY_CLK [=y] Selected by [m]: - VIDEO_TC358746 [=m] && MEDIA_SUPPORT [=m] && VIDEO_DEV [=m] && PM [=y] && I2C [=m] vim +/shutter +363 drivers/media/i2c/imx492.c 4da35cf18851012 Petko Manolov 2022-11-25 352 4da35cf18851012 Petko Manolov 2022-11-25 353 /** 4da35cf18851012 Petko Manolov 2022-11-25 354 * imx492_update_exp_gain() - Set updated exposure and gain 4da35cf18851012 Petko Manolov 2022-11-25 355 * @imx492: pointer to imx492 device 4da35cf18851012 Petko Manolov 2022-11-25 356 * @exposure: updated exposure value 4da35cf18851012 Petko Manolov 2022-11-25 357 * @gain: updated analog gain value 4da35cf18851012 Petko Manolov 2022-11-25 358 * 4da35cf18851012 Petko Manolov 2022-11-25 359 * Return: 0 if successful, error code otherwise. 4da35cf18851012 Petko Manolov 2022-11-25 360 */ 4da35cf18851012 Petko Manolov 2022-11-25 361 static int imx492_update_exp_gain(struct imx492 *imx492, u32 exposure, u32 gain) 4da35cf18851012 Petko Manolov 2022-11-25 362 { 4da35cf18851012 Petko Manolov 2022-11-25 @363 u32 lpfr, shutter; 4da35cf18851012 Petko Manolov 2022-11-25 364 int ret; 4da35cf18851012 Petko Manolov 2022-11-25 365 4da35cf18851012 Petko Manolov 2022-11-25 366 lpfr = imx492->vblank + imx492->cur_mode->height; 4da35cf18851012 Petko Manolov 2022-11-25 367 shutter = lpfr - exposure; 4da35cf18851012 Petko Manolov 2022-11-25 368 4da35cf18851012 Petko Manolov 2022-11-25 369 ret = imx492_write_reg(imx492, IMX492_REG_HOLD, 1, 1); 4da35cf18851012 Petko Manolov 2022-11-25 370 if (ret) 4da35cf18851012 Petko Manolov 2022-11-25 371 return ret; 4da35cf18851012 Petko Manolov 2022-11-25 372 4da35cf18851012 Petko Manolov 2022-11-25 373 ret = imx492_write_reg(imx492, IMX492_REG_AGAIN, 2, gain); 4da35cf18851012 Petko Manolov 2022-11-25 374 4da35cf18851012 Petko Manolov 2022-11-25 375 return ret; 4da35cf18851012 Petko Manolov 2022-11-25 376 } 4da35cf18851012 Petko Manolov 2022-11-25 377 4da35cf18851012 Petko Manolov 2022-11-25 378 /** 4da35cf18851012 Petko Manolov 2022-11-25 379 * imx492_set_ctrl() - Set subdevice control 4da35cf18851012 Petko Manolov 2022-11-25 380 * @ctrl: pointer to v4l2_ctrl structure 4da35cf18851012 Petko Manolov 2022-11-25 381 * 4da35cf18851012 Petko Manolov 2022-11-25 382 * Return: 0 if successful, error code otherwise. 4da35cf18851012 Petko Manolov 2022-11-25 383 */ 4da35cf18851012 Petko Manolov 2022-11-25 384 static int imx492_set_ctrl(struct v4l2_ctrl *ctrl) 4da35cf18851012 Petko Manolov 2022-11-25 385 { 4da35cf18851012 Petko Manolov 2022-11-25 386 struct imx492 *imx492 = 4da35cf18851012 Petko Manolov 2022-11-25 387 container_of(ctrl->handler, struct imx492, ctrl_handler); 4da35cf18851012 Petko Manolov 2022-11-25 388 u32 analog_gain; 4da35cf18851012 Petko Manolov 2022-11-25 389 u32 exposure; 4da35cf18851012 Petko Manolov 2022-11-25 390 int ret; 4da35cf18851012 Petko Manolov 2022-11-25 391 4da35cf18851012 Petko Manolov 2022-11-25 392 switch (ctrl->id) { 4da35cf18851012 Petko Manolov 2022-11-25 393 case V4L2_CID_VBLANK: 4da35cf18851012 Petko Manolov 2022-11-25 394 imx492->vblank = imx492->vblank_ctrl->val; 4da35cf18851012 Petko Manolov 2022-11-25 395 4da35cf18851012 Petko Manolov 2022-11-25 396 ret = __v4l2_ctrl_modify_range(imx492->exp_ctrl, 4da35cf18851012 Petko Manolov 2022-11-25 397 IMX492_EXPOSURE_MIN, 4da35cf18851012 Petko Manolov 2022-11-25 398 imx492->vblank + 4da35cf18851012 Petko Manolov 2022-11-25 399 imx492->cur_mode->height - 4da35cf18851012 Petko Manolov 2022-11-25 400 IMX492_EXPOSURE_OFFSET, 4da35cf18851012 Petko Manolov 2022-11-25 401 1, IMX492_EXPOSURE_DEFAULT); 4da35cf18851012 Petko Manolov 2022-11-25 402 break; 4da35cf18851012 Petko Manolov 2022-11-25 403 case V4L2_CID_EXPOSURE: 4da35cf18851012 Petko Manolov 2022-11-25 404 /* Set controls only if sensor is in power on state */ 4da35cf18851012 Petko Manolov 2022-11-25 405 if (!pm_runtime_get_if_in_use(imx492->dev)) 4da35cf18851012 Petko Manolov 2022-11-25 406 return 0; 4da35cf18851012 Petko Manolov 2022-11-25 407 exposure = ctrl->val; 4da35cf18851012 Petko Manolov 2022-11-25 408 analog_gain = imx492->again_ctrl->val; 4da35cf18851012 Petko Manolov 2022-11-25 409 ret = imx492_update_exp_gain(imx492, exposure, analog_gain); 4da35cf18851012 Petko Manolov 2022-11-25 410 pm_runtime_put(imx492->dev); 4da35cf18851012 Petko Manolov 2022-11-25 411 break; 4da35cf18851012 Petko Manolov 2022-11-25 412 case V4L2_CID_TEST_PATTERN: 4da35cf18851012 Petko Manolov 2022-11-25 413 if (ctrl->val) { 4da35cf18851012 Petko Manolov 2022-11-25 414 imx492_write_reg(imx492, IMX492_REG_TESTPATSEL, 1, ctrl->val - 1); 4da35cf18851012 Petko Manolov 2022-11-25 415 imx492_write_reg(imx492, IMX492_REG_TESTPTRN, 1, IMX492_BITS_TPTRN_ON); 4da35cf18851012 Petko Manolov 2022-11-25 416 } else { 4da35cf18851012 Petko Manolov 2022-11-25 417 imx492_write_reg(imx492, IMX492_REG_TESTPTRN, 1, IMX492_BITS_TPTRN_OFF); 4da35cf18851012 Petko Manolov 2022-11-25 418 } 4da35cf18851012 Petko Manolov 2022-11-25 419 ret = 0; 4da35cf18851012 Petko Manolov 2022-11-25 420 break; 4da35cf18851012 Petko Manolov 2022-11-25 421 default: 4da35cf18851012 Petko Manolov 2022-11-25 422 dev_err(imx492->dev, "Invalid control %d", ctrl->id); 4da35cf18851012 Petko Manolov 2022-11-25 423 ret = -EINVAL; 4da35cf18851012 Petko Manolov 2022-11-25 424 } 4da35cf18851012 Petko Manolov 2022-11-25 425 4da35cf18851012 Petko Manolov 2022-11-25 426 return ret; 4da35cf18851012 Petko Manolov 2022-11-25 427 } 4da35cf18851012 Petko Manolov 2022-11-25 428 4da35cf18851012 Petko Manolov 2022-11-25 429 /* V4l2 subdevice control ops*/ 4da35cf18851012 Petko Manolov 2022-11-25 430 static const struct v4l2_ctrl_ops imx492_ctrl_ops = { 4da35cf18851012 Petko Manolov 2022-11-25 431 .s_ctrl = imx492_set_ctrl, 4da35cf18851012 Petko Manolov 2022-11-25 432 }; 4da35cf18851012 Petko Manolov 2022-11-25 433 4da35cf18851012 Petko Manolov 2022-11-25 434 /** 4da35cf18851012 Petko Manolov 2022-11-25 435 * imx492_enum_mbus_code() - Enumerate V4L2 sub-device mbus codes 4da35cf18851012 Petko Manolov 2022-11-25 436 * @sd: pointer to imx492 V4L2 sub-device structure 4da35cf18851012 Petko Manolov 2022-11-25 437 * @sd_state: V4L2 sub-device configuration 4da35cf18851012 Petko Manolov 2022-11-25 438 * @code: V4L2 sub-device code enumeration need to be filled 4da35cf18851012 Petko Manolov 2022-11-25 439 * 4da35cf18851012 Petko Manolov 2022-11-25 440 * Return: 0 if successful, error code otherwise. 4da35cf18851012 Petko Manolov 2022-11-25 441 */ 4da35cf18851012 Petko Manolov 2022-11-25 442 static int imx492_enum_mbus_code(struct v4l2_subdev *sd, 4da35cf18851012 Petko Manolov 2022-11-25 443 struct v4l2_subdev_state *sd_state, 4da35cf18851012 Petko Manolov 2022-11-25 444 struct v4l2_subdev_mbus_code_enum *code) 4da35cf18851012 Petko Manolov 2022-11-25 445 { 4da35cf18851012 Petko Manolov 2022-11-25 446 if (code->index > ARRAY_SIZE(supported_modes)) 4da35cf18851012 Petko Manolov 2022-11-25 447 return -EINVAL; 4da35cf18851012 Petko Manolov 2022-11-25 448 4da35cf18851012 Petko Manolov 2022-11-25 449 code->code = supported_modes[code->index].code; 4da35cf18851012 Petko Manolov 2022-11-25 450 4da35cf18851012 Petko Manolov 2022-11-25 451 return 0; 4da35cf18851012 Petko Manolov 2022-11-25 452 } 4da35cf18851012 Petko Manolov 2022-11-25 453 4da35cf18851012 Petko Manolov 2022-11-25 454 /** 4da35cf18851012 Petko Manolov 2022-11-25 455 * imx492_enum_frame_size() - Enumerate V4L2 sub-device frame sizes 4da35cf18851012 Petko Manolov 2022-11-25 456 * @sd: pointer to imx492 V4L2 sub-device structure 4da35cf18851012 Petko Manolov 2022-11-25 457 * @sd_state: V4L2 sub-device configuration 4da35cf18851012 Petko Manolov 2022-11-25 458 * @fsize: V4L2 sub-device size enumeration need to be filled 4da35cf18851012 Petko Manolov 2022-11-25 459 * 4da35cf18851012 Petko Manolov 2022-11-25 460 * Return: 0 if successful, error code otherwise. 4da35cf18851012 Petko Manolov 2022-11-25 461 */ 4da35cf18851012 Petko Manolov 2022-11-25 462 static int imx492_enum_frame_size(struct v4l2_subdev *sd, 4da35cf18851012 Petko Manolov 2022-11-25 463 struct v4l2_subdev_state *sd_state, 4da35cf18851012 Petko Manolov 2022-11-25 464 struct v4l2_subdev_frame_size_enum *fsize) 4da35cf18851012 Petko Manolov 2022-11-25 465 { 4da35cf18851012 Petko Manolov 2022-11-25 466 if (fsize->index > ARRAY_SIZE(supported_modes)) 4da35cf18851012 Petko Manolov 2022-11-25 467 return -EINVAL; 4da35cf18851012 Petko Manolov 2022-11-25 468 4da35cf18851012 Petko Manolov 2022-11-25 469 if (fsize->code != supported_modes[fsize->index].code) 4da35cf18851012 Petko Manolov 2022-11-25 470 return -EINVAL; 4da35cf18851012 Petko Manolov 2022-11-25 471 4da35cf18851012 Petko Manolov 2022-11-25 472 fsize->max_width = supported_modes[fsize->index].width; 4da35cf18851012 Petko Manolov 2022-11-25 473 fsize->min_width = fsize->max_width; 4da35cf18851012 Petko Manolov 2022-11-25 474 fsize->max_height = supported_modes[fsize->index].height; 4da35cf18851012 Petko Manolov 2022-11-25 475 fsize->min_height = fsize->max_height; 4da35cf18851012 Petko Manolov 2022-11-25 476 4da35cf18851012 Petko Manolov 2022-11-25 477 return 0; 4da35cf18851012 Petko Manolov 2022-11-25 478 } 4da35cf18851012 Petko Manolov 2022-11-25 479 4da35cf18851012 Petko Manolov 2022-11-25 480 /** 4da35cf18851012 Petko Manolov 2022-11-25 @481 n * imx492_fill_pad_format() - Fill subdevice pad format 4da35cf18851012 Petko Manolov 2022-11-25 482 * from selected sensor mode 4da35cf18851012 Petko Manolov 2022-11-25 483 * @imx492: pointer to imx492 device 4da35cf18851012 Petko Manolov 2022-11-25 484 * @mode: pointer to imx492_mode sensor mode 4da35cf18851012 Petko Manolov 2022-11-25 485 * @fmt: V4L2 sub-device format need to be filled 4da35cf18851012 Petko Manolov 2022-11-25 486 */ 4da35cf18851012 Petko Manolov 2022-11-25 487 static void imx492_fill_pad_format(struct imx492 *imx492, 4da35cf18851012 Petko Manolov 2022-11-25 488 const struct imx492_mode *mode, 4da35cf18851012 Petko Manolov 2022-11-25 489 struct v4l2_subdev_format *fmt) 4da35cf18851012 Petko Manolov 2022-11-25 490 { 4da35cf18851012 Petko Manolov 2022-11-25 491 fmt->format.width = mode->width; 4da35cf18851012 Petko Manolov 2022-11-25 492 fmt->format.height = mode->height; 4da35cf18851012 Petko Manolov 2022-11-25 493 fmt->format.code = mode->code; 4da35cf18851012 Petko Manolov 2022-11-25 494 fmt->format.field = V4L2_FIELD_NONE; 4da35cf18851012 Petko Manolov 2022-11-25 495 fmt->format.colorspace = V4L2_COLORSPACE_RAW; 4da35cf18851012 Petko Manolov 2022-11-25 496 fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; 4da35cf18851012 Petko Manolov 2022-11-25 497 fmt->format.quantization = V4L2_QUANTIZATION_DEFAULT; 4da35cf18851012 Petko Manolov 2022-11-25 498 fmt->format.xfer_func = V4L2_XFER_FUNC_NONE; 4da35cf18851012 Petko Manolov 2022-11-25 499 } 4da35cf18851012 Petko Manolov 2022-11-25 500
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index ba28a8f8a07f..8cdad7e25e5e 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_VIDEO_IMX334) += imx334.o obj-$(CONFIG_VIDEO_IMX335) += imx335.o obj-$(CONFIG_VIDEO_IMX355) += imx355.o obj-$(CONFIG_VIDEO_IMX412) += imx412.o +obj-$(CONFIG_VIDEO_IMX492) += imx492.o obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o obj-$(CONFIG_VIDEO_ISL7998X) += isl7998x.o obj-$(CONFIG_VIDEO_KS0127) += ks0127.o
Make sure the driver gets compiled in case it is selected in Kconfig. Signed-off-by: Petko Manolov <petko.manolov@konsulko.com> --- drivers/media/i2c/Makefile | 1 + 1 file changed, 1 insertion(+)