1 From 898198428aa35f52c2b58c037e960dcbcc4ef9d8 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 14 Apr 2020 16:12:33 +0100
4 Subject: [PATCH] media: i2c: ov9281: Fixup for recent kernel
5 releases, and remove custom code
7 The Rockchip driver was based on a 4.4 kernel, and had several custom
10 Update to 5.4 kernel APIs, with the relevant controls required by
11 libcamera, and remove custom Rockchip parts.
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 drivers/media/i2c/Kconfig | 2 +-
16 drivers/media/i2c/ov9281.c | 361 +++++++++++++------------------------
17 2 files changed, 123 insertions(+), 240 deletions(-)
19 --- a/drivers/media/i2c/Kconfig
20 +++ b/drivers/media/i2c/Kconfig
21 @@ -857,7 +857,7 @@ config VIDEO_OV9640
24 tristate "OmniVision OV9281 sensor support"
25 - depends on I2C && VIDEO_V4L2
26 + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
27 depends on MEDIA_CAMERA_SUPPORT
29 This is a Video4Linux2 sensor-level driver for the OmniVision
30 --- a/drivers/media/i2c/ov9281.c
31 +++ b/drivers/media/i2c/ov9281.c
33 // SPDX-License-Identifier: GPL-2.0
36 + * Omnivision OV9281 1280x800 global shutter image sensor driver
38 + * This driver has been taken from
39 + * https://github.com/rockchip-linux/kernel/blob/develop-4.4/drivers/media/i2c/ov9281.c
40 + * cleaned up, made to compile against mainline kernels instead of the Rockchip
41 + * vendor kernel, and the relevant controls added to work with libcamera.
43 * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
44 * V0.0X01.0X02 fix mclk issue when probe multiple camera.
46 #include <linux/regulator/consumer.h>
47 #include <linux/sysfs.h>
48 #include <linux/slab.h>
49 -#include <linux/rk-camera-module.h>
50 #include <media/media-entity.h>
51 #include <media/v4l2-async.h>
52 #include <media/v4l2-ctrls.h>
53 #include <media/v4l2-subdev.h>
54 -#include <linux/pinctrl/consumer.h>
56 -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x3)
58 -#ifndef V4L2_CID_DIGITAL_GAIN
59 -#define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN
62 #define OV9281_LINK_FREQ_400MHZ 400000000
63 +#define OV9281_LANES 2
64 +#define OV9281_BITS_PER_SAMPLE 10
66 /* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */
67 -#define OV9281_PIXEL_RATE (OV9281_LINK_FREQ_400MHZ * 2 * 2 / 10)
68 +#define OV9281_PIXEL_RATE (OV9281_LINK_FREQ_400MHZ * 2 * \
69 + OV9281_LANES / OV9281_BITS_PER_SAMPLE)
70 #define OV9281_XVCLK_FREQ 24000000
72 #define CHIP_ID 0x9281
75 #define OV9281_REG_VTS 0x380e
78 + * OV9281 native and active pixel array size.
79 + * Datasheet not available to confirm these values, so assume there are no
82 +#define OV9281_NATIVE_WIDTH 1280U
83 +#define OV9281_NATIVE_HEIGHT 800U
84 +#define OV9281_PIXEL_ARRAY_LEFT 0U
85 +#define OV9281_PIXEL_ARRAY_TOP 0U
86 +#define OV9281_PIXEL_ARRAY_WIDTH 1280U
87 +#define OV9281_PIXEL_ARRAY_HEIGHT 800U
89 #define REG_NULL 0xFFFF
91 #define OV9281_REG_VALUE_08BIT 1
92 #define OV9281_REG_VALUE_16BIT 2
93 #define OV9281_REG_VALUE_24BIT 3
95 -#define OV9281_LANES 2
96 -#define OV9281_BITS_PER_SAMPLE 10
98 -#define OF_CAMERA_PINCTRL_STATE_DEFAULT "rockchip,camera_default"
99 -#define OF_CAMERA_PINCTRL_STATE_SLEEP "rockchip,camera_sleep"
101 #define OV9281_NAME "ov9281"
103 static const char * const ov9281_supply_names[] = {
104 @@ -93,10 +100,10 @@ struct regval {
108 - struct v4l2_fract max_fps;
112 + struct v4l2_rect crop;
113 const struct regval *reg_list;
116 @@ -107,10 +114,6 @@ struct ov9281 {
117 struct gpio_desc *pwdn_gpio;
118 struct regulator_bulk_data supplies[OV9281_NUM_SUPPLIES];
120 - struct pinctrl *pinctrl;
121 - struct pinctrl_state *pins_default;
122 - struct pinctrl_state *pins_sleep;
124 struct v4l2_subdev subdev;
125 struct media_pad pad;
126 struct v4l2_ctrl_handler ctrl_handler;
127 @@ -124,23 +127,12 @@ struct ov9281 {
130 const struct ov9281_mode *cur_mode;
132 - const char *module_facing;
133 - const char *module_name;
134 - const char *len_name;
137 #define to_ov9281(sd) container_of(sd, struct ov9281, subdev)
142 -static const struct regval ov9281_global_regs[] = {
148 * max_framerate 120fps
149 * mipi_datarate per lane 800Mbps
151 @@ -247,13 +239,15 @@ static const struct ov9281_mode supporte
156 - .numerator = 10000,
157 - .denominator = 1200000,
160 - .hts_def = 0x0b60,//0x2d8*4
161 + .hts_def = 0x05b0, /* 0x2d8*2 */
169 .reg_list = ov9281_1280x800_regs,
172 @@ -389,22 +383,28 @@ static int ov9281_set_fmt(struct v4l2_su
173 fmt->format.width = mode->width;
174 fmt->format.height = mode->height;
175 fmt->format.field = V4L2_FIELD_NONE;
176 + fmt->format.colorspace = V4L2_COLORSPACE_SRGB;
177 + fmt->format.ycbcr_enc =
178 + V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->format.colorspace);
179 + fmt->format.quantization =
180 + V4L2_MAP_QUANTIZATION_DEFAULT(true, fmt->format.colorspace,
181 + fmt->format.ycbcr_enc);
182 + fmt->format.xfer_func =
183 + V4L2_MAP_XFER_FUNC_DEFAULT(fmt->format.colorspace);
185 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
186 -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
187 *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
189 - mutex_unlock(&ov9281->mutex);
193 ov9281->cur_mode = mode;
194 h_blank = mode->hts_def - mode->width;
195 __v4l2_ctrl_modify_range(ov9281->hblank, h_blank,
196 h_blank, 1, h_blank);
197 + __v4l2_ctrl_s_ctrl(ov9281->hblank, h_blank);
198 vblank_def = mode->vts_def - mode->height;
199 __v4l2_ctrl_modify_range(ov9281->vblank, vblank_def,
200 OV9281_VTS_MAX - mode->height,
202 + __v4l2_ctrl_s_ctrl(ov9281->vblank, vblank_def);
205 mutex_unlock(&ov9281->mutex);
206 @@ -421,17 +421,21 @@ static int ov9281_get_fmt(struct v4l2_su
208 mutex_lock(&ov9281->mutex);
209 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
210 -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
211 fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
213 - mutex_unlock(&ov9281->mutex);
217 fmt->format.width = mode->width;
218 fmt->format.height = mode->height;
219 fmt->format.code = MEDIA_BUS_FMT_Y10_1X10;
220 fmt->format.field = V4L2_FIELD_NONE;
221 + fmt->format.colorspace = V4L2_COLORSPACE_SRGB;
222 + fmt->format.ycbcr_enc =
223 + V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->format.colorspace);
224 + fmt->format.quantization =
225 + V4L2_MAP_QUANTIZATION_DEFAULT(true,
226 + fmt->format.colorspace,
227 + fmt->format.ycbcr_enc);
228 + fmt->format.xfer_func =
229 + V4L2_MAP_XFER_FUNC_DEFAULT(fmt->format.colorspace);
231 mutex_unlock(&ov9281->mutex);
233 @@ -442,7 +446,7 @@ static int ov9281_enum_mbus_code(struct
234 struct v4l2_subdev_pad_config *cfg,
235 struct v4l2_subdev_mbus_code_enum *code)
237 - if (code->index != 0)
240 code->code = MEDIA_BUS_FMT_Y10_1X10;
242 @@ -480,88 +484,56 @@ static int ov9281_enable_test_pattern(st
243 OV9281_REG_VALUE_08BIT, val);
246 -static int OV9281_g_frame_interval(struct v4l2_subdev *sd,
247 - struct v4l2_subdev_frame_interval *fi)
249 - struct ov9281 *ov9281 = to_ov9281(sd);
250 - const struct ov9281_mode *mode = ov9281->cur_mode;
252 - mutex_lock(&ov9281->mutex);
253 - fi->interval = mode->max_fps;
254 - mutex_unlock(&ov9281->mutex);
255 +static const struct v4l2_rect *
256 +__ov9281_get_pad_crop(struct ov9281 *ov9281, struct v4l2_subdev_pad_config *cfg,
257 + unsigned int pad, enum v4l2_subdev_format_whence which)
260 + case V4L2_SUBDEV_FORMAT_TRY:
261 + return v4l2_subdev_get_try_crop(&ov9281->subdev, cfg, pad);
262 + case V4L2_SUBDEV_FORMAT_ACTIVE:
263 + return &ov9281->cur_mode->crop;
270 -static void ov9281_get_module_inf(struct ov9281 *ov9281,
271 - struct rkmodule_inf *inf)
272 +static int ov9281_get_selection(struct v4l2_subdev *sd,
273 + struct v4l2_subdev_pad_config *cfg,
274 + struct v4l2_subdev_selection *sel)
276 - memset(inf, 0, sizeof(*inf));
277 - strlcpy(inf->base.sensor, OV9281_NAME, sizeof(inf->base.sensor));
278 - strlcpy(inf->base.module, ov9281->module_name,
279 - sizeof(inf->base.module));
280 - strlcpy(inf->base.lens, ov9281->len_name, sizeof(inf->base.lens));
282 + switch (sel->target) {
283 + case V4L2_SEL_TGT_CROP: {
284 + struct ov9281 *ov9281 = to_ov9281(sd);
286 -static long ov9281_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
288 - struct ov9281 *ov9281 = to_ov9281(sd);
290 + mutex_lock(&ov9281->mutex);
291 + sel->r = *__ov9281_get_pad_crop(ov9281, cfg, sel->pad,
293 + mutex_unlock(&ov9281->mutex);
296 - case RKMODULE_GET_MODULE_INFO:
297 - ov9281_get_module_inf(ov9281, (struct rkmodule_inf *)arg);
300 - ret = -ENOIOCTLCMD;
307 + case V4L2_SEL_TGT_NATIVE_SIZE:
310 + sel->r.width = OV9281_NATIVE_WIDTH;
311 + sel->r.height = OV9281_NATIVE_HEIGHT;
313 -#ifdef CONFIG_COMPAT
314 -static long ov9281_compat_ioctl32(struct v4l2_subdev *sd,
315 - unsigned int cmd, unsigned long arg)
317 - void __user *up = compat_ptr(arg);
318 - struct rkmodule_inf *inf;
319 - struct rkmodule_awb_cfg *cfg;
323 - case RKMODULE_GET_MODULE_INFO:
324 - inf = kzalloc(sizeof(*inf), GFP_KERNEL);
331 - ret = ov9281_ioctl(sd, cmd, inf);
333 - ret = copy_to_user(up, inf, sizeof(*inf));
336 - case RKMODULE_AWB_CFG:
337 - cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
342 + case V4L2_SEL_TGT_CROP_DEFAULT:
343 + case V4L2_SEL_TGT_CROP_BOUNDS:
344 + sel->r.top = OV9281_PIXEL_ARRAY_TOP;
345 + sel->r.left = OV9281_PIXEL_ARRAY_LEFT;
346 + sel->r.width = OV9281_PIXEL_ARRAY_WIDTH;
347 + sel->r.height = OV9281_PIXEL_ARRAY_HEIGHT;
349 - ret = copy_from_user(cfg, up, sizeof(*cfg));
351 - ret = ov9281_ioctl(sd, cmd, cfg);
355 - ret = -ENOIOCTLCMD;
365 static int __ov9281_start_stream(struct ov9281 *ov9281)
367 @@ -643,12 +615,6 @@ static int ov9281_s_power(struct v4l2_su
368 pm_runtime_put_noidle(&client->dev);
369 goto unlock_and_return;
371 - ret = ov9281_write_array(ov9281->client, ov9281_global_regs);
373 - v4l2_err(sd, "could not set init registers\n");
374 - pm_runtime_put_noidle(&client->dev);
375 - goto unlock_and_return;
377 ov9281->power_on = true;
379 pm_runtime_put(&client->dev);
380 @@ -673,18 +639,12 @@ static int __ov9281_power_on(struct ov92
382 struct device *dev = &ov9281->client->dev;
384 - if (!IS_ERR_OR_NULL(ov9281->pins_default)) {
385 - ret = pinctrl_select_state(ov9281->pinctrl,
386 - ov9281->pins_default);
388 - dev_err(dev, "could not set pins\n");
391 ret = clk_set_rate(ov9281->xvclk, OV9281_XVCLK_FREQ);
393 dev_warn(dev, "Failed to set xvclk rate (24MHz)\n");
394 if (clk_get_rate(ov9281->xvclk) != OV9281_XVCLK_FREQ)
395 - dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n");
396 + dev_warn(dev, "xvclk mismatched, modes are based on 24MHz - rate is %lu\n",
397 + clk_get_rate(ov9281->xvclk));
399 ret = clk_prepare_enable(ov9281->xvclk);
401 @@ -722,20 +682,11 @@ disable_clk:
403 static void __ov9281_power_off(struct ov9281 *ov9281)
406 - struct device *dev = &ov9281->client->dev;
408 if (!IS_ERR(ov9281->pwdn_gpio))
409 gpiod_set_value_cansleep(ov9281->pwdn_gpio, 0);
410 clk_disable_unprepare(ov9281->xvclk);
411 if (!IS_ERR(ov9281->reset_gpio))
412 gpiod_set_value_cansleep(ov9281->reset_gpio, 0);
413 - if (!IS_ERR_OR_NULL(ov9281->pins_sleep)) {
414 - ret = pinctrl_select_state(ov9281->pinctrl,
415 - ov9281->pins_sleep);
417 - dev_dbg(dev, "could not set pins\n");
419 regulator_bulk_disable(OV9281_NUM_SUPPLIES, ov9281->supplies);
422 @@ -759,7 +710,6 @@ static int ov9281_runtime_suspend(struct
426 -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
427 static int ov9281_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
429 struct ov9281 *ov9281 = to_ov9281(sd);
430 @@ -773,61 +723,42 @@ static int ov9281_open(struct v4l2_subde
431 try_fmt->height = def_mode->height;
432 try_fmt->code = MEDIA_BUS_FMT_Y10_1X10;
433 try_fmt->field = V4L2_FIELD_NONE;
434 + try_fmt->colorspace = V4L2_COLORSPACE_SRGB;
435 + try_fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(try_fmt->colorspace);
436 + try_fmt->quantization =
437 + V4L2_MAP_QUANTIZATION_DEFAULT(true, try_fmt->colorspace,
438 + try_fmt->ycbcr_enc);
439 + try_fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(try_fmt->colorspace);
441 mutex_unlock(&ov9281->mutex);
442 /* No crop or compose */
449 -ov9281_enum_frame_interval(struct v4l2_subdev *sd,
450 - struct v4l2_subdev_pad_config *cfg,
451 - struct v4l2_subdev_frame_interval_enum *fie)
453 - if (fie->index >= ARRAY_SIZE(supported_modes))
456 - if (fie->code != MEDIA_BUS_FMT_Y10_1X10)
459 - fie->width = supported_modes[fie->index].width;
460 - fie->height = supported_modes[fie->index].height;
461 - fie->interval = supported_modes[fie->index].max_fps;
465 static const struct dev_pm_ops ov9281_pm_ops = {
466 SET_RUNTIME_PM_OPS(ov9281_runtime_suspend,
467 ov9281_runtime_resume, NULL)
470 -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
471 static const struct v4l2_subdev_internal_ops ov9281_internal_ops = {
476 static const struct v4l2_subdev_core_ops ov9281_core_ops = {
477 .s_power = ov9281_s_power,
478 - .ioctl = ov9281_ioctl,
479 -#ifdef CONFIG_COMPAT
480 - .compat_ioctl32 = ov9281_compat_ioctl32,
484 static const struct v4l2_subdev_video_ops ov9281_video_ops = {
485 .s_stream = ov9281_s_stream,
486 - .g_frame_interval = OV9281_g_frame_interval,
489 static const struct v4l2_subdev_pad_ops ov9281_pad_ops = {
490 .enum_mbus_code = ov9281_enum_mbus_code,
491 .enum_frame_size = ov9281_enum_frame_sizes,
492 - .enum_frame_interval = ov9281_enum_frame_interval,
493 .get_fmt = ov9281_get_fmt,
494 .set_fmt = ov9281_set_fmt,
495 + .get_selection = ov9281_get_selection,
498 static const struct v4l2_subdev_ops ov9281_subdev_ops = {
499 @@ -868,7 +799,8 @@ static int ov9281_set_ctrl(struct v4l2_c
500 case V4L2_CID_ANALOGUE_GAIN:
501 ret = ov9281_write_reg(ov9281->client, OV9281_REG_GAIN_H,
502 OV9281_REG_VALUE_08BIT,
503 - (ctrl->val >> OV9281_GAIN_H_SHIFT) & OV9281_GAIN_H_MASK);
504 + (ctrl->val >> OV9281_GAIN_H_SHIFT) &
505 + OV9281_GAIN_H_MASK);
506 ret |= ov9281_write_reg(ov9281->client, OV9281_REG_GAIN_L,
507 OV9281_REG_VALUE_08BIT,
508 ctrl->val & OV9281_GAIN_L_MASK);
509 @@ -922,31 +854,34 @@ static int ov9281_initialize_controls(st
511 h_blank = mode->hts_def - mode->width;
512 ov9281->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK,
513 - h_blank, h_blank, 1, h_blank);
514 + h_blank, h_blank, 1, h_blank);
516 ov9281->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
518 vblank_def = mode->vts_def - mode->height;
519 ov9281->vblank = v4l2_ctrl_new_std(handler, &ov9281_ctrl_ops,
520 - V4L2_CID_VBLANK, vblank_def,
521 - OV9281_VTS_MAX - mode->height,
523 + V4L2_CID_VBLANK, vblank_def,
524 + OV9281_VTS_MAX - mode->height, 1,
527 exposure_max = mode->vts_def - 4;
528 ov9281->exposure = v4l2_ctrl_new_std(handler, &ov9281_ctrl_ops,
529 - V4L2_CID_EXPOSURE, OV9281_EXPOSURE_MIN,
530 - exposure_max, OV9281_EXPOSURE_STEP,
533 + OV9281_EXPOSURE_MIN, exposure_max,
534 + OV9281_EXPOSURE_STEP,
537 ov9281->anal_gain = v4l2_ctrl_new_std(handler, &ov9281_ctrl_ops,
538 - V4L2_CID_ANALOGUE_GAIN, OV9281_GAIN_MIN,
539 - OV9281_GAIN_MAX, OV9281_GAIN_STEP,
540 - OV9281_GAIN_DEFAULT);
542 - ov9281->test_pattern = v4l2_ctrl_new_std_menu_items(handler,
543 - &ov9281_ctrl_ops, V4L2_CID_TEST_PATTERN,
544 - ARRAY_SIZE(ov9281_test_pattern_menu) - 1,
545 - 0, 0, ov9281_test_pattern_menu);
546 + V4L2_CID_ANALOGUE_GAIN,
547 + OV9281_GAIN_MIN, OV9281_GAIN_MAX,
549 + OV9281_GAIN_DEFAULT);
551 + ov9281->test_pattern =
552 + v4l2_ctrl_new_std_menu_items(handler, &ov9281_ctrl_ops,
553 + V4L2_CID_TEST_PATTERN,
554 + ARRAY_SIZE(ov9281_test_pattern_menu) - 1,
555 + 0, 0, ov9281_test_pattern_menu);
557 if (handler->error) {
558 ret = handler->error;
559 @@ -1000,34 +935,14 @@ static int ov9281_probe(struct i2c_clien
560 const struct i2c_device_id *id)
562 struct device *dev = &client->dev;
563 - struct device_node *node = dev->of_node;
564 struct ov9281 *ov9281;
565 struct v4l2_subdev *sd;
569 - dev_info(dev, "driver version: %02x.%02x.%02x",
570 - DRIVER_VERSION >> 16,
571 - (DRIVER_VERSION & 0xff00) >> 8,
572 - DRIVER_VERSION & 0x00ff);
574 ov9281 = devm_kzalloc(dev, sizeof(*ov9281), GFP_KERNEL);
578 - ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX,
579 - &ov9281->module_index);
580 - ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING,
581 - &ov9281->module_facing);
582 - ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_NAME,
583 - &ov9281->module_name);
584 - ret |= of_property_read_string(node, RKMODULE_CAMERA_LENS_NAME,
585 - &ov9281->len_name);
587 - dev_err(dev, "could not get module information!\n");
591 ov9281->client = client;
592 ov9281->cur_mode = &supported_modes[0];
594 @@ -1037,31 +952,15 @@ static int ov9281_probe(struct i2c_clien
598 - ov9281->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
599 + ov9281->reset_gpio = devm_gpiod_get_optional(dev, "reset",
601 if (IS_ERR(ov9281->reset_gpio))
602 dev_warn(dev, "Failed to get reset-gpios\n");
604 - ov9281->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW);
605 + ov9281->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_LOW);
606 if (IS_ERR(ov9281->pwdn_gpio))
607 dev_warn(dev, "Failed to get pwdn-gpios\n");
609 - ov9281->pinctrl = devm_pinctrl_get(dev);
610 - if (!IS_ERR(ov9281->pinctrl)) {
611 - ov9281->pins_default =
612 - pinctrl_lookup_state(ov9281->pinctrl,
613 - OF_CAMERA_PINCTRL_STATE_DEFAULT);
614 - if (IS_ERR(ov9281->pins_default))
615 - dev_err(dev, "could not get default pinstate\n");
617 - ov9281->pins_sleep =
618 - pinctrl_lookup_state(ov9281->pinctrl,
619 - OF_CAMERA_PINCTRL_STATE_SLEEP);
620 - if (IS_ERR(ov9281->pins_sleep))
621 - dev_err(dev, "could not get sleep pinstate\n");
623 - dev_err(dev, "no pinctrl\n");
626 ret = ov9281_configure_regulators(ov9281);
628 dev_err(dev, "Failed to get power regulators\n");
629 @@ -1084,26 +983,16 @@ static int ov9281_probe(struct i2c_clien
633 -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
634 sd->internal_ops = &ov9281_internal_ops;
635 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
637 -#if defined(CONFIG_MEDIA_CONTROLLER)
639 ov9281->pad.flags = MEDIA_PAD_FL_SOURCE;
640 - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
641 - ret = media_entity_init(&sd->entity, 1, &ov9281->pad, 0);
642 + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
643 + ret = media_entity_pads_init(&sd->entity, 1, &ov9281->pad);
648 - memset(facing, 0, sizeof(facing));
649 - if (strcmp(ov9281->module_facing, "back") == 0)
654 - snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s",
655 - ov9281->module_index, facing,
656 + snprintf(sd->name, sizeof(sd->name), "m%s %s",
657 OV9281_NAME, dev_name(sd->dev));
658 ret = v4l2_async_register_subdev_sensor_common(sd);
660 @@ -1118,9 +1007,7 @@ static int ov9281_probe(struct i2c_clien
664 -#if defined(CONFIG_MEDIA_CONTROLLER)
665 media_entity_cleanup(&sd->entity);
668 __ov9281_power_off(ov9281);
670 @@ -1137,9 +1024,7 @@ static int ov9281_remove(struct i2c_clie
671 struct ov9281 *ov9281 = to_ov9281(sd);
673 v4l2_async_unregister_subdev(sd);
674 -#if defined(CONFIG_MEDIA_CONTROLLER)
675 media_entity_cleanup(&sd->entity);
677 v4l2_ctrl_handler_free(&ov9281->ctrl_handler);
678 mutex_destroy(&ov9281->mutex);
680 @@ -1151,13 +1036,11 @@ static int ov9281_remove(struct i2c_clie
684 -#if IS_ENABLED(CONFIG_OF)
685 static const struct of_device_id ov9281_of_match[] = {
686 { .compatible = "ovti,ov9281" },
689 MODULE_DEVICE_TABLE(of, ov9281_of_match);
692 static const struct i2c_device_id ov9281_match_id[] = {
693 { "ovti,ov9281", 0 },