diff --git a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_api.h b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_api.h index b9d2ca535644..d954db1c28fe 100644 --- a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_api.h +++ b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_api.h @@ -21,8 +21,6 @@ #include "maxim2c_pattern.h" #include "maxim2c_drv.h" -#define MAXIM2C_NAME "maxim2c" - /* Maxim Deserializer Test Pattern */ #define MAXIM2C_TEST_PATTERN 0 diff --git a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.c b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.c index fa35f8915abd..7438a159efad 100644 --- a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.c +++ b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.c @@ -28,6 +28,12 @@ * 1. fixed remote camera s_stream and s_power api return error. * 2. compatible with kernel v4.19/v5.10/v6.1 * + * V3.02.00 + * 1. support remote dummy sensor + * 2. record the status of the serializer + * 3. remote serializer support more chip id + * 4. support mode add crop rect dts config + * */ #include #include @@ -55,7 +61,9 @@ #include "maxim2c_api.h" -#define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) +#define DRIVER_VERSION KERNEL_VERSION(3, 0x02, 0x00) + +#define MAXIM2C_NAME "maxim2c" #define MAXIM2C_XVCLK_FREQ 25000000 @@ -609,6 +617,8 @@ static int maxim2c_probe(struct i2c_client *client, maxim2c->client = client; maxim2c->chipid = chip_id; + maxim2c->sensor_name = MAXIM2C_NAME; + ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX, &maxim2c->module_index); ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING, diff --git a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.h b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.h index 9711cb08d443..45991dda2f59 100644 --- a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.h +++ b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_drv.h @@ -99,6 +99,7 @@ typedef struct maxim2c { const char *module_facing; const char *module_name; const char *len_name; + const char *sensor_name; maxim2c_gmsl_link_t gmsl_link; maxim2c_video_pipe_t video_pipe; diff --git a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_v4l2.c b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_v4l2.c index 766c21ab9d6a..584cfab6c2af 100644 --- a/drivers/media/i2c/maxim/local/maxim2c/maxim2c_v4l2.c +++ b/drivers/media/i2c/maxim/local/maxim2c/maxim2c_v4l2.c @@ -307,7 +307,7 @@ static void maxim2c_get_module_inf(maxim2c_t *maxim2c, struct rkmodule_inf *inf) { memset(inf, 0, sizeof(*inf)); - strscpy(inf->base.sensor, MAXIM2C_NAME, sizeof(inf->base.sensor)); + strscpy(inf->base.sensor, maxim2c->sensor_name, sizeof(inf->base.sensor)); strscpy(inf->base.module, maxim2c->module_name, sizeof(inf->base.module)); strscpy(inf->base.lens, maxim2c->len_name, sizeof(inf->base.lens)); @@ -1082,7 +1082,7 @@ int maxim2c_v4l2_subdev_init(maxim2c_t *maxim2c) facing[0] = 'f'; snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", - maxim2c->module_index, facing, MAXIM2C_NAME, + maxim2c->module_index, facing, maxim2c->sensor_name, dev_name(sd->dev)); #if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE diff --git a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_api.h b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_api.h index 31a1fc6b20c6..4944595ce43e 100644 --- a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_api.h +++ b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_api.h @@ -21,8 +21,6 @@ #include "maxim4c_pattern.h" #include "maxim4c_drv.h" -#define MAXIM4C_NAME "maxim4c" - /* Maxim Deserializer Test Pattern */ #define MAXIM4C_TEST_PATTERN 0 diff --git a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.c b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.c index fceea4605700..b326d4762b00 100644 --- a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.c +++ b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.c @@ -51,6 +51,12 @@ * 1. fixed remote camera s_stream and s_power api return error. * 2. compatible with kernel v4.19/v5.10/v6.1 * + * V3.02.00 + * 1. support remote dummy sensor + * 2. record the status of the serializer + * 3. remote serializer support more chip id + * 4. support mode add crop rect dts config + * */ #include #include @@ -78,7 +84,9 @@ #include "maxim4c_api.h" -#define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) +#define DRIVER_VERSION KERNEL_VERSION(3, 0x02, 0x00) + +#define MAXIM4C_NAME "maxim4c" #define MAXIM4C_XVCLK_FREQ 25000000 @@ -676,6 +684,8 @@ static int maxim4c_probe(struct i2c_client *client, maxim4c->client = client; maxim4c->chipid = chip_id; + maxim4c->sensor_name = MAXIM4C_NAME; + ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX, &maxim4c->module_index); ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING, diff --git a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.h b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.h index d4485fea0bbb..df355dff0755 100644 --- a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.h +++ b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_drv.h @@ -99,6 +99,7 @@ typedef struct maxim4c { const char *module_facing; const char *module_name; const char *len_name; + const char *sensor_name; maxim4c_gmsl_link_t gmsl_link; maxim4c_video_pipe_t video_pipe; diff --git a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_v4l2.c b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_v4l2.c index 9498c265d634..d517f5b71adb 100644 --- a/drivers/media/i2c/maxim/local/maxim4c/maxim4c_v4l2.c +++ b/drivers/media/i2c/maxim/local/maxim4c/maxim4c_v4l2.c @@ -307,7 +307,7 @@ static void maxim4c_get_module_inf(maxim4c_t *maxim4c, struct rkmodule_inf *inf) { memset(inf, 0, sizeof(*inf)); - strscpy(inf->base.sensor, MAXIM4C_NAME, sizeof(inf->base.sensor)); + strscpy(inf->base.sensor, maxim4c->sensor_name, sizeof(inf->base.sensor)); strscpy(inf->base.module, maxim4c->module_name, sizeof(inf->base.module)); strscpy(inf->base.lens, maxim4c->len_name, sizeof(inf->base.lens)); @@ -1082,7 +1082,7 @@ int maxim4c_v4l2_subdev_init(maxim4c_t *maxim4c) facing[0] = 'f'; snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", - maxim4c->module_index, facing, MAXIM4C_NAME, + maxim4c->module_index, facing, maxim4c->sensor_name, dev_name(sd->dev)); #if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE diff --git a/drivers/media/i2c/maxim/remote/max9295.c b/drivers/media/i2c/maxim/remote/max9295.c index ea3d20bc47dc..789567332b3b 100644 --- a/drivers/media/i2c/maxim/remote/max9295.c +++ b/drivers/media/i2c/maxim/remote/max9295.c @@ -12,11 +12,12 @@ #include #include #include +#include #include #include "maxim_remote.h" -#define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) +#define DRIVER_VERSION KERNEL_VERSION(3, 0x02, 0x00) #define MAX9295_NAME "maxim-max9295" @@ -334,13 +335,15 @@ static int max9295_check_chipid(maxim_remote_ser_t *max9295) max9295_i2c_addr_def(max9295); } - if (chip_id != MAX9295_CHIP_ID) { - dev_err(dev, "Unexpected chip id = %02x\n", chip_id); - return -ENODEV; + if (chip_id == max9295->chip_id) { + if (chip_id == MAX9295_CHIP_ID) { + dev_info(dev, "MAX9295 is Detected\n"); + return 0; + } } - dev_info(dev, "Detected MAX9295 chip id: 0x%02x\n", chip_id); - return 0; + dev_err(dev, "Unexpected MAX9295 chipid = %02x\n", chip_id); + return -ENODEV; } /* @@ -506,10 +509,19 @@ static int max9295_probe(struct i2c_client *client, { struct device *dev = &client->dev; maxim_remote_ser_t *max9295 = NULL; + u32 chip_id; dev_info(dev, "driver version: %02x.%02x.%02x", DRIVER_VERSION >> 16, (DRIVER_VERSION & 0xff00) >> 8, DRIVER_VERSION & 0x00ff); + chip_id = (uintptr_t)of_device_get_match_data(dev); + if (chip_id == MAX9295_CHIP_ID) { + dev_info(dev, "driver for max9295\n"); + } else { + dev_err(dev, "driver unknown chip\n"); + return -EINVAL; + } + max9295 = devm_kzalloc(dev, sizeof(*max9295), GFP_KERNEL); if (!max9295) { dev_err(dev, "max9295 probe no memory error\n"); @@ -517,6 +529,7 @@ static int max9295_probe(struct i2c_client *client, } max9295->client = client; + max9295->chip_id = chip_id; max9295->ser_i2c_addr_map = client->addr; max9295->ser_ops = &max9295_ser_ops; max9295->ser_state = MAXIM_REMOTE_SER_DEINIT; @@ -550,7 +563,10 @@ static void max9295_remove(struct i2c_client *client) } static const struct of_device_id max9295_of_match[] = { - { .compatible = "maxim,ser,max9295" }, + { + .compatible = "maxim,ser,max9295", + .data = (const void *)MAX9295_CHIP_ID + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, max9295_of_match); diff --git a/drivers/media/i2c/maxim/remote/max96715.c b/drivers/media/i2c/maxim/remote/max96715.c index 1d568468b9b5..d2f9c6f98d16 100644 --- a/drivers/media/i2c/maxim/remote/max96715.c +++ b/drivers/media/i2c/maxim/remote/max96715.c @@ -12,11 +12,12 @@ #include #include #include +#include #include #include "maxim_remote.h" -#define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) +#define DRIVER_VERSION KERNEL_VERSION(3, 0x02, 0x00) #define MAX96715_NAME "maxim-max96715" @@ -367,13 +368,15 @@ static int max96715_check_chipid(maxim_remote_ser_t *max96715) max96715_i2c_addr_def(max96715); } - if (chip_id != MAX96715_CHIP_ID) { - dev_err(dev, "Unexpected chip id = %02x\n", chip_id); - return -ENODEV; + if (chip_id == max96715->chip_id) { + if (chip_id == MAX96715_CHIP_ID) { + dev_info(dev, "MAX96715 is Detected\n"); + return 0; + } } - dev_info(dev, "Detected MAX96715 chip id: 0x%02x\n", chip_id); - return 0; + dev_err(dev, "Unexpected MAX96715 chipid = %02x\n", chip_id); + return -ENODEV; } /* @@ -507,10 +510,19 @@ static int max96715_probe(struct i2c_client *client, { struct device *dev = &client->dev; maxim_remote_ser_t *max96715 = NULL; + u32 chip_id; dev_info(dev, "driver version: %02x.%02x.%02x", DRIVER_VERSION >> 16, (DRIVER_VERSION & 0xff00) >> 8, DRIVER_VERSION & 0x00ff); + chip_id = (uintptr_t)of_device_get_match_data(dev); + if (chip_id == MAX96715_CHIP_ID) { + dev_info(dev, "driver for max96715\n"); + } else { + dev_err(dev, "driver unknown chip\n"); + return -EINVAL; + } + max96715 = devm_kzalloc(dev, sizeof(*max96715), GFP_KERNEL); if (!max96715) { dev_err(dev, "max96715 probe no memory error\n"); @@ -518,6 +530,7 @@ static int max96715_probe(struct i2c_client *client, } max96715->client = client; + max96715->chip_id = chip_id; max96715->ser_i2c_addr_map = client->addr; max96715->ser_ops = &max96715_ser_ops; max96715->ser_state = MAXIM_REMOTE_SER_DEINIT; @@ -551,7 +564,10 @@ static void max96715_remove(struct i2c_client *client) } static const struct of_device_id max96715_of_match[] = { - { .compatible = "maxim,ser,max96715" }, + { + .compatible = "maxim,ser,max96715", + .data = (const void *)MAX96715_CHIP_ID + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, max96715_of_match); diff --git a/drivers/media/i2c/maxim/remote/max96717.c b/drivers/media/i2c/maxim/remote/max96717.c index 209f8b4c0d06..975fe9ac49e2 100644 --- a/drivers/media/i2c/maxim/remote/max96717.c +++ b/drivers/media/i2c/maxim/remote/max96717.c @@ -12,17 +12,19 @@ #include #include #include +#include #include #include "maxim_remote.h" -#define DRIVER_VERSION KERNEL_VERSION(3, 0x01, 0x00) +#define DRIVER_VERSION KERNEL_VERSION(3, 0x02, 0x00) #define MAX96717_NAME "maxim-max96717" #define MAX96717_I2C_ADDR_DEF 0x40 #define MAX96717_CHIP_ID 0xBF +#define MAX96717F_CHIP_ID 0xC8 #define MAX96717_REG_CHIP_ID 0x0D /* register address: 16bit */ @@ -334,13 +336,20 @@ static int max96717_check_chipid(maxim_remote_ser_t *max96717) max96717_i2c_addr_def(max96717); } - if (chip_id != MAX96717_CHIP_ID) { - dev_err(dev, "Unexpected chip id = %02x\n", chip_id); - return -ENODEV; - } - dev_info(dev, "Detected MAX96717 chip id: 0x%02x\n", chip_id); + if (chip_id == max96717->chip_id) { + if (chip_id == MAX96717_CHIP_ID) { + dev_info(dev, "MAX96717 is Detected\n"); + return 0; + } - return 0; + if (chip_id == MAX96717F_CHIP_ID) { + dev_info(dev, "MAX96717F is Detected\n"); + return 0; + } + } + + dev_err(dev, "Unexpected MAX96717 chipid = %02x\n", chip_id); + return -ENODEV; } /* @@ -456,10 +465,21 @@ static int max96717_probe(struct i2c_client *client, { struct device *dev = &client->dev; maxim_remote_ser_t *max96717 = NULL; + u32 chip_id; dev_info(dev, "driver version: %02x.%02x.%02x", DRIVER_VERSION >> 16, (DRIVER_VERSION & 0xff00) >> 8, DRIVER_VERSION & 0x00ff); + chip_id = (uintptr_t)of_device_get_match_data(dev); + if (chip_id == MAX96717_CHIP_ID) { + dev_info(dev, "driver for max96717\n"); + } else if (chip_id == MAX96717F_CHIP_ID) { + dev_info(dev, "driver for max96717f\n"); + } else { + dev_err(dev, "driver unknown chip\n"); + return -EINVAL; + } + max96717 = devm_kzalloc(dev, sizeof(*max96717), GFP_KERNEL); if (!max96717) { dev_err(dev, "max96717 probe no memory error\n"); @@ -467,6 +487,7 @@ static int max96717_probe(struct i2c_client *client, } max96717->client = client; + max96717->chip_id = chip_id; max96717->ser_i2c_addr_map = client->addr; max96717->ser_ops = &max96717_ser_ops; max96717->ser_state = MAXIM_REMOTE_SER_DEINIT; @@ -500,7 +521,14 @@ static void max96717_remove(struct i2c_client *client) } static const struct of_device_id max96717_of_match[] = { - { .compatible = "maxim,ser,max96717" }, + { + .compatible = "maxim,ser,max96717", + .data = (const void *)MAX96717_CHIP_ID + }, + { + .compatible = "maxim,ser,max96717f", + .data = (const void *)MAX96717F_CHIP_ID + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, max96717_of_match); diff --git a/drivers/media/i2c/maxim/remote/maxim_remote.h b/drivers/media/i2c/maxim/remote/maxim_remote.h index 692871d81e0e..46d23a6a0a85 100644 --- a/drivers/media/i2c/maxim/remote/maxim_remote.h +++ b/drivers/media/i2c/maxim/remote/maxim_remote.h @@ -74,6 +74,8 @@ typedef struct maxim_remote_ser { struct mutex mutex; + u32 chip_id; + u8 ser_i2c_addr_def; u8 ser_i2c_addr_map; diff --git a/drivers/media/i2c/maxim/remote/ox03j10.c b/drivers/media/i2c/maxim/remote/ox03j10.c index 7f5a742c3fda..3bcead6bdca2 100644 --- a/drivers/media/i2c/maxim/remote/ox03j10.c +++ b/drivers/media/i2c/maxim/remote/ox03j10.c @@ -99,7 +99,7 @@ struct ox03j10 { struct maxim_remote_ser *remote_ser; }; -static const struct i2c_regval ox03j10_1920x1080_regs[] = { +static const struct i2c_regval ox03j10_1920x1280_regs[] = { { REG_NULL, 0x00 }, }; @@ -118,15 +118,15 @@ static const struct i2c_regval ox03j10_1920x1080_regs[] = { static const struct ox03j10_mode supported_modes[] = { { .width = 1920, - .height = 1080, + .height = 1280, .max_fps = { .numerator = 10000, .denominator = 300000, }, .link_freq_idx = 0, - .bus_fmt = MEDIA_BUS_FMT_UYVY8_2X8, + .bus_fmt = MEDIA_BUS_FMT_YUYV8_2X8, .bpp = 16, - .reg_list = ox03j10_1920x1080_regs, + .reg_list = ox03j10_1920x1280_regs, } };