Add MT9M021 Driver patches to Kernel

This commit is contained in:
dchvs 2021-02-09 16:06:28 -06:00
parent 38986adb21
commit f578b99243
4 changed files with 152 additions and 1 deletions

View File

@ -989,7 +989,7 @@ int camera_common_initialize(struct camera_common_data *s_data,
const char *dev_name)
{
int err = 0;
char debugfs_name[10];
char debugfs_name[50];
if (s_data->dev == NULL)
return -EINVAL;

View File

@ -33,6 +33,18 @@
#define TEGRACAM_DEF_CTRLS 1
/* MT9M021 Controls Information */
#define MT9M021_DEFAULT_ANALOG_GAIN (0x0)
#define MT9M021_MAX_ANALOG_GAIN (0x3)
static const char * const mt9m021_test_pattern_menu[] = {
"0:Disabled",
"1:Solid color test pattern",
"2:color bar test pattern",
"3:Fade to gray color bar test pattern",
"256:Walking 1s test pattern (12 bit)"
};
static int tegracam_s_ctrl(struct v4l2_ctrl *ctrl);
static const struct v4l2_ctrl_ops tegracam_ctrl_ops = {
.s_ctrl = tegracam_s_ctrl,
@ -163,6 +175,109 @@ static struct v4l2_ctrl_config ctrl_cfg_list[] = {
.max = CTRL_MAX_STR_SIZE,
.step = 2,
},
/* Controls extension for MT9M021 */
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_ANALOGUE_GAIN,
.name = "Analog Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = CTRL_U64_MIN,
.max = MT9M021_MAX_ANALOG_GAIN,
.def = MT9M021_DEFAULT_ANALOG_GAIN,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_GAIN_RED,
.name = "Red Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = CTRL_U64_MIN,
.max = CTRL_U64_MAX,
.def = CTRL_U64_MIN,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_GAIN_GREENR,
.name = "GreenR Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = CTRL_U64_MIN,
.max = CTRL_U64_MAX,
.def = CTRL_U64_MIN,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_GAIN_GREENB,
.name = "GreenB Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = CTRL_U64_MIN,
.max = CTRL_U64_MAX,
.def = CTRL_U64_MIN,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_GAIN_BLUE,
.name = "Blue Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = CTRL_U64_MIN,
.max = CTRL_U64_MAX,
.def = CTRL_U64_MIN,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_TEST_PATTERN,
.type = V4L2_CTRL_TYPE_MENU,
.name = "Test Pattern",
.min = 0,
.max = ARRAY_SIZE(mt9m021_test_pattern_menu) - 1,
.step = 0,
.def = 0,
.flags = 0,
.menu_skip_mask = 0,
.qmenu = mt9m021_test_pattern_menu,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_FLASH_LED_MODE,
.name = "Flash",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = 0,
.min = V4L2_FLASH_LED_MODE_NONE,
.max = V4L2_FLASH_LED_MODE_FLASH,
.def = V4L2_FLASH_LED_MODE_FLASH,
.step = 1,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_HFLIP,
.name = "Horizontal Flip",
.type = V4L2_CTRL_TYPE_INTEGER_MENU,
.min = 0,
.max = ARRAY_SIZE(switch_ctrl_qmenu) - 1,
.menu_skip_mask = 0,
.def = 0,
.qmenu_int = switch_ctrl_qmenu,
},
{
.ops = &tegracam_ctrl_ops,
.id = V4L2_CID_VFLIP,
.name = "Vertical Flip",
.type = V4L2_CTRL_TYPE_INTEGER_MENU,
.min = 0,
.max = ARRAY_SIZE(switch_ctrl_qmenu) - 1,
.menu_skip_mask = 0,
.def = 0,
.qmenu_int = switch_ctrl_qmenu,
},
};
static int tegracam_get_ctrl_index(u32 cid)
@ -266,6 +381,26 @@ static int tegracam_set_ctrls(struct tegracam_ctrl_handler *handler,
case TEGRA_CAMERA_CID_GROUP_HOLD:
err = ops->set_group_hold(tc_dev, ctrl->val);
break;
case V4L2_CID_ANALOGUE_GAIN:
err = ops->set_analog_gain(tc_dev, *ctrl->p_new.p_s64);
break;
case V4L2_CID_GAIN_RED:
case V4L2_CID_GAIN_GREENR:
case V4L2_CID_GAIN_GREENB:
case V4L2_CID_GAIN_BLUE:
err = ops->set_digital_gain(tc_dev, *ctrl->p_new.p_s64,
ctrl->id);
break;
case V4L2_CID_TEST_PATTERN:
err = ops->set_test_pattern(tc_dev, ctrl->val);
break;
case V4L2_CID_FLASH_LED_MODE:
err = ops->set_flash(tc_dev, ctrl->val);
break;
case V4L2_CID_HFLIP:
case V4L2_CID_VFLIP:
err = ops->set_flip(tc_dev, ctrl->val, ctrl->id);
break;
default:
pr_err("%s: unknown ctrl id.\n", __func__);
return -EINVAL;
@ -459,6 +594,10 @@ int tegracam_init_ctrl_ranges_by_mode(
switch (ctrl->id) {
case TEGRA_CAMERA_CID_GAIN:
case V4L2_CID_GAIN_RED:
case V4L2_CID_GAIN_GREENR:
case V4L2_CID_GAIN_GREENB:
case V4L2_CID_GAIN_BLUE:
err = v4l2_ctrl_modify_range(ctrl,
ctrlprops->min_gain_val,
ctrlprops->max_gain_val,

View File

@ -205,6 +205,12 @@ struct tegracam_ctrl_ops {
struct sensor_blob *blob, s64 val);
int (*set_group_hold_ex)(struct tegracam_device *tc_dev,
struct sensor_blob *blob, bool val);
int (*set_analog_gain)(struct tegracam_device *tc_dev, s64 val);
int (*set_digital_gain)(struct tegracam_device *tc_dev, s64 val,
int id);
int (*set_test_pattern)(struct tegracam_device *tc_dev, s32 val);
int (*set_flash)(struct tegracam_device *tc_dev, s32 val);
int (*set_flip)(struct tegracam_device *tc_dev, s32 val, int id);
};
struct tegracam_ctrl_handler {

View File

@ -55,6 +55,12 @@
#define TEGRA_CAMERA_CID_LOW_LATENCY (TEGRA_CAMERA_CID_BASE+109)
#define TEGRA_CAMERA_CID_VI_PREFERRED_STRIDE (TEGRA_CAMERA_CID_BASE+110)
/* Custom Controls */
#define V4L2_CID_GAIN_RED V4L2_CID_USER_BASE
#define V4L2_CID_GAIN_GREENR V4L2_CID_USER_BASE + 1
#define V4L2_CID_GAIN_GREENB V4L2_CID_USER_BASE + 2
#define V4L2_CID_GAIN_BLUE V4L2_CID_USER_BASE + 3
/**
* This is temporary with the current v4l2 infrastructure
* currently discussing with upstream maintainers our proposals and