update(media): update sensor mirror.

This commit is contained in:
kangjun 2025-04-29 10:52:42 +08:00
parent 796620b3ab
commit 1868c85e8d
5 changed files with 117 additions and 9 deletions

View File

@ -12,7 +12,7 @@ max_cache_buffer_size = 204800 # KB
av_sync_duration = 0 # millisecond
# picture num for modules
pic_4list_num = 3
pic_4list_num = 2
pic_4di_num = 0
pic_4rotate_num = 0
pic_4smooth_num = 0

View File

@ -21,6 +21,8 @@
#include <media/v4l2-device.h>
#include <media/v4l2-mediabus.h>
#include <linux/io.h>
// #include <linux/device.h>
#include <linux/sysfs.h>
#include "camera.h"
#include "sensor_helper.h"
@ -1506,13 +1508,56 @@ static int sensor_init_controls(struct v4l2_subdev *sd, const struct v4l2_ctrl_o
return ret;
}
static int sensor_dev_id;
#if 1
static int standby_state;
static ssize_t standby_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
// 假设通过读取寄存器获取standby状态
// standby_state = i2c_read(sd, REG_STANDBY_STATUS);
// standby_state = 0; // 这里需要根据硬件实现获取当前状态
return sprintf(buf, "%d\n", standby_state);
}
static ssize_t standby_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
int value, ret;
// 将用户输入的字符串转换为整数
if (kstrtoint(buf, 10, &value))
return -EINVAL;
// 根据value的值调用sensor_power函数
if (value == 1) {
ret = sensor_power(sd, STBY_ON); // 进入standby模式
} else if (value == 0) {
ret = sensor_power(sd, STBY_OFF); // 退出standby模式
} else {
return -EINVAL; // 非法输入
}
if (ret)
return ret;
return count;
}
static DEVICE_ATTR_RW(standby);
#endif
static int sensor_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct v4l2_subdev *sd;
struct sensor_info *info;
int i;
int ret;
info = kzalloc(sizeof(struct sensor_info), GFP_KERNEL);
if (info == NULL)
@ -1531,6 +1576,13 @@ static int sensor_probe(struct i2c_client *client,
sensor_init_controls(sd, &sensor_ctrl_ops);
standby_state = 0;
ret = sysfs_create_file(&client->dev.kobj, &dev_attr_standby.attr);
if (ret) {
sensor_err("failed to create device file [standby]\n");
return ret;
}
mutex_init(&info->lock);
info->fmt = &sensor_formats[0];
@ -1557,6 +1609,9 @@ static int sensor_remove(struct i2c_client *client)
int i;
if (client) {
/* 移除设备属性文件 */
sysfs_remove_file(&client->dev.kobj, &dev_attr_standby.attr);
for (i = 0; i < SENSOR_NUM; i++) {
if (!strcmp(cci_drv[i].name, client->name))
break;

View File

@ -134,7 +134,7 @@ static struct regval_list sensor_800x600_30_regs[] = {
{0x3213, 0x02},
{0x3215, 0x31},
{0x3220, 0x01},
{0x3221,0x60},
{0x3221, 0x06},
{0x3248, 0x02},
{0x3253, 0x0a},
{0x3301, 0xff},
@ -239,7 +239,7 @@ static struct regval_list sensor_800x600_30_regs[] = {
static struct regval_list sensor_1600x1200_30_regs[] = {
{0x0103,0x01},
{0x0100,0x00},
{0x3221,0x60},//hflip:0x06 vflip:0x60
{0x3221,0x06},//hflip:0x06 vflip:0x60
{0x36e9,0x80},
{0x36e9,0x24},
{0x301f,0x01},
@ -737,7 +737,7 @@ static int sensor_s_hflip(struct v4l2_subdev *sd, int enable)
static int sensor_get_fmt_mbus_core(struct v4l2_subdev *sd, int *code)
{
*code = MEDIA_BUS_FMT_SRGGB10_1X10;//;MEDIA_BUS_FMT_SBGGR10_1X10;
*code = MEDIA_BUS_FMT_SBGGR10_1X10;//MEDIA_BUS_FMT_SRGGB10_1X10;//
return 0;
}
@ -1158,7 +1158,7 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
static struct sensor_format_struct sensor_formats[] = {
{
.desc = "Raw RGB Bayer",
.mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,//MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.regs = sensor_fmt_raw,
.regs_size = ARRAY_SIZE(sensor_fmt_raw),
.bpp = 1
@ -1493,12 +1493,58 @@ static int sensor_init_controls(struct v4l2_subdev *sd, const struct v4l2_ctrl_o
}
static int sensor_dev_id;
#if 1
static int standby_state;
static ssize_t standby_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
// 假设通过读取寄存器获取standby状态
// standby_state = i2c_read(sd, REG_STANDBY_STATUS);
// standby_state = 0; // 这里需要根据硬件实现获取当前状态
return sprintf(buf, "%d\n", standby_state);
}
static ssize_t standby_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
int value, ret;
// 将用户输入的字符串转换为整数
if (kstrtoint(buf, 10, &value))
return -EINVAL;
// 根据value的值调用sensor_power函数
if (value == 1) {
// ret = sensor_power(sd, STBY_ON); // 进入standby模式
ret = sensor_write(sd, 0x0100, 0x00); //sleep enable
} else if (value == 0) {
// ret = sensor_power(sd, STBY_OFF); // 退出standby模式
ret = sensor_write(sd, 0x0100, 0x01); //sleep disable
} else {
return -EINVAL; // 非法输入
}
if (ret)
return ret;
return count;
}
static DEVICE_ATTR_RW(standby);
#endif
static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct v4l2_subdev *sd;
struct sensor_info *info;
int i = 0;
int ret;
printk("===========xxxxx client name:%s, slave:0x%x\n", client->name, client->addr);
info = kzalloc(sizeof(struct sensor_info), GFP_KERNEL);
if (info == NULL)
@ -1518,6 +1564,13 @@ static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *i
sensor_init_controls(sd, &sensor_ctrl_ops);
standby_state = 0;
ret = sysfs_create_file(&client->dev.kobj, &dev_attr_standby.attr);
if (ret) {
sensor_err("failed to create device file [standby]\n");
return ret;
}
mutex_init(&info->lock);
sensor_print("========ywj_dg_add==============\n");

View File

@ -117,7 +117,7 @@ static struct regval_list sensor_800x600_30_regs[] = {
{0x3213, 0x02},
{0x3215, 0x31},
{0x3220, 0x01},
{0x3221, 0x60},
{0x3221, 0x06},
{0x3248, 0x02},
{0x3253, 0x0a},
{0x3301, 0xff},
@ -340,7 +340,7 @@ static struct regval_list sensor_800x600_30_regs[] = {
static struct regval_list sensor_1600x1200_30_regs[] = {
{0x0103,0x01},
{0x0100,0x00},
{0x3221,0x60},//hflip:0x06 vflip:0x60
{0x3221,0x06},//hflip:0x06 vflip:0x60
{0x36e9,0x80},
{0x36e9,0x24},
{0x301f,0x01},
@ -695,7 +695,7 @@ static int sensor_init(int id)
static struct sensor_format_struct sensor_formats[] = {
#ifdef SC2356_800X600_30FPS
{
.mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,//MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SRGGB10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.width = 800,
.height = 600,//1080,
.hoffset = 0,
@ -719,7 +719,7 @@ static struct sensor_format_struct sensor_formats[] = {
#ifdef SC2356_1600X1200_30FPS
{
.mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,//MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SRGGB10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
.width = 1600,
.height = 1200,//1080,
.hoffset = 0,