From 9370bb92b2d16684ee45cf24e879c93c509162da Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Thu, 19 Dec 2024 01:47:39 +0000 Subject: [PATCH] add wifi6 8852be driver --- kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 92 insertions(+), 17 deletions(-) diff --git a/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c b/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c index d1faaf0..432cc06 100644 --- a/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c +++ b/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* * jaguar1 driver - * - * V0.0X01.0X01 add workqueue to detect ahd state. + * V0.0X01.0X00 first version. + * V0.0X01.0X01 fix kernel5.10 compile error. + * V0.0X01.0X02 add workqueue to detect ahd state. * */ @@ -39,6 +40,7 @@ #include "jaguar1_video_eq.h" #include "jaguar1_mipi.h" #include "jaguar1_drv.h" +#include "jaguar1_v4l2.h" #define WORK_QUEUE @@ -52,7 +54,7 @@ #endif -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x1) +#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x2) #ifndef V4L2_CID_DIGITAL_GAIN #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN @@ -81,14 +83,6 @@ /* #define FORCE_720P */ -enum jaguar1_max_pad { - PAD0, - PAD1, - PAD2, - PAD3, - PAD_MAX, -}; - struct jaguar1_gpio { int pltfrm_gpio; const char *label; @@ -113,7 +107,9 @@ struct jaguar1_framesize { u16 width; u16 height; + struct v4l2_fract max_fps; enum NC_VIVO_CH_FORMATDEF fmt_idx; + __u32 field; }; struct jaguar1_default_rect { @@ -176,23 +172,62 @@ { .width = 2560, .height = 1440, + .max_fps = { + .numerator = 10000, + .denominator = 250000, + }, .fmt_idx = AHD20_720P_25P, } #else { + .width = 960, + .height = 480, + .max_fps = { + .numerator = 10000, + .denominator = 250000, + }, + .fmt_idx = AHD20_SD_H960_2EX_Btype_NT, + .field = V4L2_FIELD_INTERLACED, + }, + { + .width = 960, + .height = 576, + .max_fps = { + .numerator = 10000, + .denominator = 300000, + }, + .fmt_idx = AHD20_SD_H960_2EX_Btype_PAL, + .field = V4L2_FIELD_INTERLACED, + }, + { .width = 1280, .height = 720, + .max_fps = { + .numerator = 10000, + .denominator = 250000, + }, .fmt_idx = AHD20_720P_25P_EX_Btype, + .field = V4L2_FIELD_NONE }, { .width = 1920, .height = 1080, + .max_fps = { + .numerator = 10000, + .denominator = 250000, + }, .fmt_idx = AHD20_1080P_25P, + .field = V4L2_FIELD_NONE }, { .width = 2560, .height = 1440, + .max_fps = { + .numerator = 10000, + .denominator = 250000, + }, .fmt_idx = AHD20_720P_25P, + .field = V4L2_FIELD_NONE } #endif }; @@ -479,7 +514,7 @@ format->colorspace = V4L2_COLORSPACE_SRGB; format->code = jaguar1_formats[0].code; jaguar1->frame_size = match; - format->field = V4L2_FIELD_NONE; + format->field = match->field; } static inline bool jaguar1_no_signal(struct v4l2_subdev *sd, u8 *novid); @@ -716,13 +751,29 @@ return 0; } -static int jaguar1_g_mbus_config(struct v4l2_subdev *sd, +static int jaguar1_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_config *cfg) { - cfg->type = V4L2_MBUS_CSI2; + cfg->type = V4L2_MBUS_CSI2_DPHY; cfg->flags = V4L2_MBUS_CSI2_4_LANE | V4L2_MBUS_CSI2_CHANNELS | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; + + return 0; +} + +static int jaguar1_enum_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_interval_enum *fie) +{ + if (fie->index >= ARRAY_SIZE(jaguar1_framesizes)) + return -EINVAL; + + fie->code = jaguar1_formats[0].code; + + fie->width = jaguar1_framesizes[fie->index].width; + fie->height = jaguar1_framesizes[fie->index].height; + fie->interval = jaguar1_framesizes[fie->index].max_fps; return 0; } @@ -831,6 +882,19 @@ mutex_unlock(&jaguar1->mutex); return ret; +} + +static int jaguar1_g_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_frame_interval *fi) +{ + struct jaguar1 *jaguar1 = to_jaguar1(sd); + const struct jaguar1_framesize *size = jaguar1->frame_size; + + mutex_lock(&jaguar1->mutex); + fi->interval = size->max_fps; + mutex_unlock(&jaguar1->mutex); + + return 0; } static void jaguar1_get_module_inf(struct jaguar1 *jaguar1, @@ -1043,14 +1107,16 @@ static const struct v4l2_subdev_video_ops jaguar1_video_ops = { .g_input_status = jaguar1_g_input_status, .s_stream = jaguar1_stream, - .g_mbus_config = jaguar1_g_mbus_config, + .g_frame_interval = jaguar1_g_frame_interval, }; static const struct v4l2_subdev_pad_ops jaguar1_subdev_pad_ops = { .enum_mbus_code = jaguar1_enum_mbus_code, .enum_frame_size = jaguar1_enum_frame_sizes, + .enum_frame_interval = jaguar1_enum_frame_interval, .get_fmt = jaguar1_get_fmt, .set_fmt = jaguar1_set_fmt, + .get_mbus_config = jaguar1_g_mbus_config, }; static const struct v4l2_subdev_core_ops jaguar1_core_ops = { @@ -1248,6 +1314,10 @@ sd = &jaguar1->subdev; v4l2_i2c_subdev_init(sd, client, &jaguar1_subdev_ops); ret = jaguar1_initialize_controls(jaguar1); + if (ret) { + dev_err(dev, "Failed to initialize controls jaguar1\n"); + return ret; + } __jaguar1_power_on(jaguar1); ret |= jaguar1_init(i2c_adapter_id(client->adapter)); @@ -1298,6 +1368,8 @@ pm_runtime_enable(dev); pm_runtime_idle(dev); + v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, + client->addr << 1, client->adapter->name); #ifdef WORK_QUEUE /* init work_queue for state_check */ INIT_DELAYED_WORK(&jaguar1->plug_state_check.d_work, jaguar1_plug_state_check_work); @@ -1371,17 +1443,20 @@ .id_table = jaguar1_match_id, }; -static int __init sensor_mod_init(void) +int nvp6324_sensor_mod_init(void) { return i2c_add_driver(&jaguar1_i2c_driver); } + +#ifndef CONFIG_VIDEO_REVERSE_IMAGE +device_initcall_sync(nvp6324_sensor_mod_init); +#endif static void __exit sensor_mod_exit(void) { i2c_del_driver(&jaguar1_i2c_driver); } -device_initcall_sync(sensor_mod_init); module_exit(sensor_mod_exit); MODULE_DESCRIPTION("jaguar1 sensor driver"); -- Gitblit v1.6.2