| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | 2 | /* |
|---|
| 3 | | - * SC301IOT driver |
|---|
| 3 | + * sc301iot driver |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Copyright (C) 2022 Fuzhou Rockchip Electronics Co., Ltd. |
|---|
| 6 | 6 | * |
|---|
| .. | .. |
|---|
| 110 | 110 | #define OF_CAMERA_PINCTRL_STATE_DEFAULT "rockchip,camera_default" |
|---|
| 111 | 111 | #define OF_CAMERA_PINCTRL_STATE_SLEEP "rockchip,camera_sleep" |
|---|
| 112 | 112 | #define OF_CAMERA_HDR_MODE "rockchip,camera-hdr-mode" |
|---|
| 113 | | -#define SC301IOT_NAME "SC301IOT" |
|---|
| 113 | +#define SC301IOT_NAME "sc301iot" |
|---|
| 114 | 114 | |
|---|
| 115 | 115 | static const char * const SC301IOT_supply_names[] = { |
|---|
| 116 | 116 | "avdd", /* Analog power */ |
|---|
| .. | .. |
|---|
| 125 | 125 | u8 val; |
|---|
| 126 | 126 | }; |
|---|
| 127 | 127 | |
|---|
| 128 | | -struct SC301IOT_mode { |
|---|
| 128 | +struct sc301iot_mode { |
|---|
| 129 | 129 | u32 bus_fmt; |
|---|
| 130 | 130 | u32 width; |
|---|
| 131 | 131 | u32 height; |
|---|
| .. | .. |
|---|
| 138 | 138 | u32 vc[PAD_MAX]; |
|---|
| 139 | 139 | }; |
|---|
| 140 | 140 | |
|---|
| 141 | | -struct SC301IOT { |
|---|
| 141 | +struct sc301iot { |
|---|
| 142 | 142 | struct i2c_client *client; |
|---|
| 143 | 143 | struct clk *xvclk; |
|---|
| 144 | 144 | struct gpio_desc *reset_gpio; |
|---|
| .. | .. |
|---|
| 162 | 162 | struct v4l2_fract cur_fps; |
|---|
| 163 | 163 | bool streaming; |
|---|
| 164 | 164 | bool power_on; |
|---|
| 165 | | - const struct SC301IOT_mode *cur_mode; |
|---|
| 165 | + const struct sc301iot_mode *cur_mode; |
|---|
| 166 | 166 | u32 module_index; |
|---|
| 167 | 167 | const char *module_facing; |
|---|
| 168 | 168 | const char *module_name; |
|---|
| .. | .. |
|---|
| 175 | 175 | u32 sync_mode; |
|---|
| 176 | 176 | }; |
|---|
| 177 | 177 | |
|---|
| 178 | | -#define to_SC301IOT(sd) container_of(sd, struct SC301IOT, subdev) |
|---|
| 178 | +#define to_sc301iot(sd) container_of(sd, struct sc301iot, subdev) |
|---|
| 179 | 179 | |
|---|
| 180 | 180 | /* |
|---|
| 181 | 181 | * Xclk 24Mhz |
|---|
| 182 | 182 | */ |
|---|
| 183 | | -static const struct regval SC301IOT_global_regs[] = { |
|---|
| 183 | +static const struct regval sc301iot_global_regs[] = { |
|---|
| 184 | 184 | {REG_NULL, 0x00}, |
|---|
| 185 | 185 | }; |
|---|
| 186 | 186 | |
|---|
| .. | .. |
|---|
| 189 | 189 | * max_framerate 30fps |
|---|
| 190 | 190 | * mipi_datarate per lane 540Mbps, 2lane |
|---|
| 191 | 191 | */ |
|---|
| 192 | | -static const struct regval SC301IOT_linear_10_2048x1536_regs[] = { |
|---|
| 192 | +static const struct regval sc301iot_linear_10_2048x1536_regs[] = { |
|---|
| 193 | 193 | {0x0103, 0x01}, |
|---|
| 194 | 194 | {0x0100, 0x00}, |
|---|
| 195 | 195 | {0x36e9, 0x80}, |
|---|
| .. | .. |
|---|
| 344 | 344 | * max_framerate 30fps |
|---|
| 345 | 345 | * mipi_datarate per lane 1080Mbps, HDR 2lane |
|---|
| 346 | 346 | */ |
|---|
| 347 | | -static const struct regval SC301IOT_hdr_10_2048x1536_regs[] = { |
|---|
| 347 | +static const struct regval sc301iot_hdr_10_2048x1536_regs[] = { |
|---|
| 348 | 348 | {0x0103, 0x01}, |
|---|
| 349 | 349 | {0x0100, 0x00}, |
|---|
| 350 | 350 | {0x36e9, 0x80}, |
|---|
| .. | .. |
|---|
| 508 | 508 | * max_framerate 30fps |
|---|
| 509 | 509 | * mipi_datarate per lane 540Mbps, 2lane |
|---|
| 510 | 510 | */ |
|---|
| 511 | | -static const struct regval SC301IOT_linear_10_1536x1536_regs[] = { |
|---|
| 511 | +static const struct regval sc301iot_linear_10_1536x1536_regs[] = { |
|---|
| 512 | 512 | {0x0103, 0x01}, |
|---|
| 513 | 513 | {0x0100, 0x00}, |
|---|
| 514 | 514 | {0x36e9, 0x80}, |
|---|
| .. | .. |
|---|
| 664 | 664 | * max_framerate 30fps |
|---|
| 665 | 665 | * mipi_datarate per lane 1080Mbps, HDR 2lane |
|---|
| 666 | 666 | */ |
|---|
| 667 | | -static const struct regval SC301IOT_hdr_10_1536x1536_regs[] = { |
|---|
| 667 | +static const struct regval sc301iot_hdr_10_1536x1536_regs[] = { |
|---|
| 668 | 668 | {0x0103, 0x01}, |
|---|
| 669 | 669 | {0x0100, 0x00}, |
|---|
| 670 | 670 | {0x36e9, 0x80}, |
|---|
| .. | .. |
|---|
| 824 | 824 | {REG_NULL, 0x00}, |
|---|
| 825 | 825 | }; |
|---|
| 826 | 826 | |
|---|
| 827 | | -static const struct SC301IOT_mode supported_modes[] = { |
|---|
| 827 | +static const struct sc301iot_mode supported_modes[] = { |
|---|
| 828 | 828 | { |
|---|
| 829 | 829 | .width = 2048, |
|---|
| 830 | 830 | .height = 1536, |
|---|
| .. | .. |
|---|
| 836 | 836 | .hts_def = 0x8ca, |
|---|
| 837 | 837 | .vts_def = 0x640, |
|---|
| 838 | 838 | .bus_fmt = MEDIA_BUS_FMT_SBGGR10_1X10, |
|---|
| 839 | | - .reg_list = SC301IOT_linear_10_2048x1536_regs, |
|---|
| 839 | + .reg_list = sc301iot_linear_10_2048x1536_regs, |
|---|
| 840 | 840 | .hdr_mode = NO_HDR, |
|---|
| 841 | 841 | .vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_0, |
|---|
| 842 | 842 | }, { |
|---|
| .. | .. |
|---|
| 850 | 850 | .hts_def = 0x8ca, |
|---|
| 851 | 851 | .vts_def = 0xc80, |
|---|
| 852 | 852 | .bus_fmt = MEDIA_BUS_FMT_SBGGR10_1X10, |
|---|
| 853 | | - .reg_list = SC301IOT_hdr_10_2048x1536_regs, |
|---|
| 853 | + .reg_list = sc301iot_hdr_10_2048x1536_regs, |
|---|
| 854 | 854 | .hdr_mode = HDR_X2, |
|---|
| 855 | 855 | .vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_1, |
|---|
| 856 | 856 | .vc[PAD1] = V4L2_MBUS_CSI2_CHANNEL_0,//L->csi wr0 |
|---|
| .. | .. |
|---|
| 867 | 867 | .hts_def = 0x8ca, |
|---|
| 868 | 868 | .vts_def = 0x640, |
|---|
| 869 | 869 | .bus_fmt = MEDIA_BUS_FMT_SBGGR10_1X10, |
|---|
| 870 | | - .reg_list = SC301IOT_linear_10_1536x1536_regs, |
|---|
| 870 | + .reg_list = sc301iot_linear_10_1536x1536_regs, |
|---|
| 871 | 871 | .hdr_mode = NO_HDR, |
|---|
| 872 | 872 | .vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_0, |
|---|
| 873 | 873 | }, { |
|---|
| .. | .. |
|---|
| 881 | 881 | .hts_def = 0x8ca, |
|---|
| 882 | 882 | .vts_def = 0xc80, |
|---|
| 883 | 883 | .bus_fmt = MEDIA_BUS_FMT_SBGGR10_1X10, |
|---|
| 884 | | - .reg_list = SC301IOT_hdr_10_1536x1536_regs, |
|---|
| 884 | + .reg_list = sc301iot_hdr_10_1536x1536_regs, |
|---|
| 885 | 885 | .hdr_mode = HDR_X2, |
|---|
| 886 | 886 | .vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_1, |
|---|
| 887 | 887 | .vc[PAD1] = V4L2_MBUS_CSI2_CHANNEL_0,//L->csi wr0 |
|---|
| .. | .. |
|---|
| 894 | 894 | SC301IOT_LINK_FREQ_594 |
|---|
| 895 | 895 | }; |
|---|
| 896 | 896 | |
|---|
| 897 | | -static const char * const SC301IOT_test_pattern_menu[] = { |
|---|
| 897 | +static const char * const sc301iot_test_pattern_menu[] = { |
|---|
| 898 | 898 | "Disabled", |
|---|
| 899 | 899 | "Vertical Color Bar Type 1", |
|---|
| 900 | 900 | "Vertical Color Bar Type 2", |
|---|
| .. | .. |
|---|
| 903 | 903 | }; |
|---|
| 904 | 904 | |
|---|
| 905 | 905 | /* Write registers up to 4 at a time */ |
|---|
| 906 | | -static int SC301IOT_write_reg(struct i2c_client *client, u16 reg, |
|---|
| 906 | +static int sc301iot_write_reg(struct i2c_client *client, u16 reg, |
|---|
| 907 | 907 | u32 len, u32 val) |
|---|
| 908 | 908 | { |
|---|
| 909 | 909 | u32 buf_i, val_i; |
|---|
| .. | .. |
|---|
| 931 | 931 | return 0; |
|---|
| 932 | 932 | } |
|---|
| 933 | 933 | |
|---|
| 934 | | -static int SC301IOT_write_array(struct i2c_client *client, |
|---|
| 934 | +static int sc301iot_write_array(struct i2c_client *client, |
|---|
| 935 | 935 | const struct regval *regs) |
|---|
| 936 | 936 | { |
|---|
| 937 | 937 | u32 i; |
|---|
| 938 | 938 | int ret = 0; |
|---|
| 939 | 939 | |
|---|
| 940 | 940 | for (i = 0; ret == 0 && regs[i].addr != REG_NULL; i++) |
|---|
| 941 | | - ret = SC301IOT_write_reg(client, regs[i].addr, |
|---|
| 941 | + ret = sc301iot_write_reg(client, regs[i].addr, |
|---|
| 942 | 942 | SC301IOT_REG_VALUE_08BIT, regs[i].val); |
|---|
| 943 | 943 | |
|---|
| 944 | 944 | return ret; |
|---|
| 945 | 945 | } |
|---|
| 946 | 946 | |
|---|
| 947 | 947 | /* Read registers up to 4 at a time */ |
|---|
| 948 | | -static int SC301IOT_read_reg(struct i2c_client *client, u16 reg, unsigned int len, |
|---|
| 948 | +static int sc301iot_read_reg(struct i2c_client *client, u16 reg, unsigned int len, |
|---|
| 949 | 949 | u32 *val) |
|---|
| 950 | 950 | { |
|---|
| 951 | 951 | struct i2c_msg msgs[2]; |
|---|
| .. | .. |
|---|
| 983 | 983 | |
|---|
| 984 | 984 | |
|---|
| 985 | 985 | /* mode: 0 = lgain 1 = sgain */ |
|---|
| 986 | | -static int SC301IOT_set_gain_reg(struct SC301IOT *SC301IOT, u32 gain, int mode) |
|---|
| 986 | +static int sc301iot_set_gain_reg(struct sc301iot *sc301iot, u32 gain, int mode) |
|---|
| 987 | 987 | { |
|---|
| 988 | 988 | u8 ANA_Coarse_gain_reg = 0x00, DIG_Fine_gain_reg = 0x80; |
|---|
| 989 | 989 | u32 ANA_Coarse_gain = 1024, DIG_gain_reg = 0x00; |
|---|
| .. | .. |
|---|
| 1026 | 1026 | DIG_Fine_gain_reg = gain/8; |
|---|
| 1027 | 1027 | |
|---|
| 1028 | 1028 | if (mode == SC301IOT_LGAIN) { |
|---|
| 1029 | | - ret = SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1029 | + ret = sc301iot_write_reg(sc301iot->client, |
|---|
| 1030 | 1030 | SC301IOT_REG_DIG_GAIN, |
|---|
| 1031 | 1031 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1032 | 1032 | DIG_gain_reg & 0xF); |
|---|
| 1033 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1033 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1034 | 1034 | SC301IOT_REG_DIG_FINE_GAIN, |
|---|
| 1035 | 1035 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1036 | 1036 | DIG_Fine_gain_reg); |
|---|
| 1037 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1037 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1038 | 1038 | SC301IOT_REG_ANA_GAIN, |
|---|
| 1039 | 1039 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1040 | 1040 | ANA_Coarse_gain_reg); |
|---|
| 1041 | 1041 | } else { |
|---|
| 1042 | | - ret = SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1042 | + ret = sc301iot_write_reg(sc301iot->client, |
|---|
| 1043 | 1043 | SC301IOT_REG_SDIG_GAIN, |
|---|
| 1044 | 1044 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1045 | 1045 | DIG_gain_reg & 0xF); |
|---|
| 1046 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1046 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1047 | 1047 | SC301IOT_REG_SDIG_FINE_GAIN, |
|---|
| 1048 | 1048 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1049 | 1049 | DIG_Fine_gain_reg); |
|---|
| 1050 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1050 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1051 | 1051 | SC301IOT_REG_SANA_GAIN, |
|---|
| 1052 | 1052 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1053 | 1053 | ANA_Coarse_gain_reg); |
|---|
| .. | .. |
|---|
| 1055 | 1055 | return ret; |
|---|
| 1056 | 1056 | } |
|---|
| 1057 | 1057 | |
|---|
| 1058 | | -static int SC301IOT_set_hdrae(struct SC301IOT *SC301IOT, |
|---|
| 1058 | +static int sc301iot_set_hdrae(struct sc301iot *sc301iot, |
|---|
| 1059 | 1059 | struct preisp_hdrae_exp_s *ae) |
|---|
| 1060 | 1060 | { |
|---|
| 1061 | 1061 | int ret = 0; |
|---|
| 1062 | 1062 | u32 l_exp_time, m_exp_time, s_exp_time; |
|---|
| 1063 | 1063 | u32 l_a_gain, m_a_gain, s_a_gain; |
|---|
| 1064 | 1064 | |
|---|
| 1065 | | - if (!SC301IOT->has_init_exp && !SC301IOT->streaming) { |
|---|
| 1066 | | - SC301IOT->init_hdrae_exp = *ae; |
|---|
| 1067 | | - SC301IOT->has_init_exp = true; |
|---|
| 1068 | | - dev_dbg(&SC301IOT->client->dev, "SC301IOT don't stream, record exp for hdr!\n"); |
|---|
| 1065 | + if (!sc301iot->has_init_exp && !sc301iot->streaming) { |
|---|
| 1066 | + sc301iot->init_hdrae_exp = *ae; |
|---|
| 1067 | + sc301iot->has_init_exp = true; |
|---|
| 1068 | + dev_dbg(&sc301iot->client->dev, "sc301iot don't stream, record exp for hdr!\n"); |
|---|
| 1069 | 1069 | return ret; |
|---|
| 1070 | 1070 | } |
|---|
| 1071 | 1071 | l_exp_time = ae->long_exp_reg; |
|---|
| .. | .. |
|---|
| 1075 | 1075 | m_a_gain = ae->middle_gain_reg; |
|---|
| 1076 | 1076 | s_a_gain = ae->short_gain_reg; |
|---|
| 1077 | 1077 | |
|---|
| 1078 | | - dev_dbg(&SC301IOT->client->dev, |
|---|
| 1078 | + dev_dbg(&sc301iot->client->dev, |
|---|
| 1079 | 1079 | "rev exp req: L_exp: 0x%x, 0x%x, M_exp: 0x%x, 0x%x S_exp: 0x%x, 0x%x\n", |
|---|
| 1080 | 1080 | l_exp_time, m_exp_time, s_exp_time, |
|---|
| 1081 | 1081 | l_a_gain, m_a_gain, s_a_gain); |
|---|
| 1082 | 1082 | |
|---|
| 1083 | | - if (SC301IOT->cur_mode->hdr_mode == HDR_X2) { |
|---|
| 1083 | + if (sc301iot->cur_mode->hdr_mode == HDR_X2) { |
|---|
| 1084 | 1084 | //2 stagger |
|---|
| 1085 | 1085 | l_a_gain = m_a_gain; |
|---|
| 1086 | 1086 | l_exp_time = m_exp_time; |
|---|
| .. | .. |
|---|
| 1097 | 1097 | if (s_exp_time > 182) //(191 - 9) |
|---|
| 1098 | 1098 | s_exp_time = 182; |
|---|
| 1099 | 1099 | |
|---|
| 1100 | | - ret = SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1100 | + ret = sc301iot_write_reg(sc301iot->client, |
|---|
| 1101 | 1101 | SC301IOT_REG_EXPOSURE_H, |
|---|
| 1102 | 1102 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1103 | 1103 | SC301IOT_FETCH_EXP_H(l_exp_time)); |
|---|
| 1104 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1104 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1105 | 1105 | SC301IOT_REG_EXPOSURE_M, |
|---|
| 1106 | 1106 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1107 | 1107 | SC301IOT_FETCH_EXP_M(l_exp_time)); |
|---|
| 1108 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1108 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1109 | 1109 | SC301IOT_REG_EXPOSURE_L, |
|---|
| 1110 | 1110 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1111 | 1111 | SC301IOT_FETCH_EXP_L(l_exp_time)); |
|---|
| 1112 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1112 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1113 | 1113 | SC301IOT_REG_SEXPOSURE_M, |
|---|
| 1114 | 1114 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1115 | 1115 | SC301IOT_FETCH_EXP_M(s_exp_time)); |
|---|
| 1116 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1116 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1117 | 1117 | SC301IOT_REG_SEXPOSURE_L, |
|---|
| 1118 | 1118 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1119 | 1119 | SC301IOT_FETCH_EXP_L(s_exp_time)); |
|---|
| 1120 | 1120 | |
|---|
| 1121 | 1121 | |
|---|
| 1122 | | - ret |= SC301IOT_set_gain_reg(SC301IOT, l_a_gain, SC301IOT_LGAIN); |
|---|
| 1123 | | - ret |= SC301IOT_set_gain_reg(SC301IOT, s_a_gain, SC301IOT_SGAIN); |
|---|
| 1122 | + ret |= sc301iot_set_gain_reg(sc301iot, l_a_gain, SC301IOT_LGAIN); |
|---|
| 1123 | + ret |= sc301iot_set_gain_reg(sc301iot, s_a_gain, SC301IOT_SGAIN); |
|---|
| 1124 | 1124 | return ret; |
|---|
| 1125 | 1125 | } |
|---|
| 1126 | 1126 | |
|---|
| 1127 | | -static int SC301IOT_get_reso_dist(const struct SC301IOT_mode *mode, |
|---|
| 1127 | +static int sc301iot_get_reso_dist(const struct sc301iot_mode *mode, |
|---|
| 1128 | 1128 | struct v4l2_mbus_framefmt *framefmt) |
|---|
| 1129 | 1129 | { |
|---|
| 1130 | 1130 | return abs(mode->width - framefmt->width) + |
|---|
| 1131 | 1131 | abs(mode->height - framefmt->height); |
|---|
| 1132 | 1132 | } |
|---|
| 1133 | 1133 | |
|---|
| 1134 | | -static const struct SC301IOT_mode * |
|---|
| 1135 | | -SC301IOT_find_best_fit(struct v4l2_subdev_format *fmt) |
|---|
| 1134 | +static const struct sc301iot_mode * |
|---|
| 1135 | +sc301iot_find_best_fit(struct v4l2_subdev_format *fmt) |
|---|
| 1136 | 1136 | { |
|---|
| 1137 | 1137 | struct v4l2_mbus_framefmt *framefmt = &fmt->format; |
|---|
| 1138 | 1138 | int dist; |
|---|
| .. | .. |
|---|
| 1141 | 1141 | unsigned int i; |
|---|
| 1142 | 1142 | |
|---|
| 1143 | 1143 | for (i = 0; i < ARRAY_SIZE(supported_modes); i++) { |
|---|
| 1144 | | - dist = SC301IOT_get_reso_dist(&supported_modes[i], framefmt); |
|---|
| 1144 | + dist = sc301iot_get_reso_dist(&supported_modes[i], framefmt); |
|---|
| 1145 | 1145 | if (cur_best_fit_dist == -1 || dist < cur_best_fit_dist) { |
|---|
| 1146 | 1146 | cur_best_fit_dist = dist; |
|---|
| 1147 | 1147 | cur_best_fit = i; |
|---|
| .. | .. |
|---|
| 1151 | 1151 | return &supported_modes[cur_best_fit]; |
|---|
| 1152 | 1152 | } |
|---|
| 1153 | 1153 | |
|---|
| 1154 | | -static int SC301IOT_set_fmt(struct v4l2_subdev *sd, |
|---|
| 1154 | +static int sc301iot_set_fmt(struct v4l2_subdev *sd, |
|---|
| 1155 | 1155 | struct v4l2_subdev_pad_config *cfg, |
|---|
| 1156 | 1156 | struct v4l2_subdev_format *fmt) |
|---|
| 1157 | 1157 | { |
|---|
| 1158 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1159 | | - const struct SC301IOT_mode *mode; |
|---|
| 1158 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1159 | + const struct sc301iot_mode *mode; |
|---|
| 1160 | 1160 | s64 h_blank, vblank_def; |
|---|
| 1161 | 1161 | |
|---|
| 1162 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1162 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1163 | 1163 | |
|---|
| 1164 | | - mode = SC301IOT_find_best_fit(fmt); |
|---|
| 1164 | + mode = sc301iot_find_best_fit(fmt); |
|---|
| 1165 | 1165 | fmt->format.code = mode->bus_fmt; |
|---|
| 1166 | 1166 | fmt->format.width = mode->width; |
|---|
| 1167 | 1167 | fmt->format.height = mode->height; |
|---|
| .. | .. |
|---|
| 1170 | 1170 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
|---|
| 1171 | 1171 | *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; |
|---|
| 1172 | 1172 | #else |
|---|
| 1173 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1173 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1174 | 1174 | return -ENOTTY; |
|---|
| 1175 | 1175 | #endif |
|---|
| 1176 | 1176 | } else { |
|---|
| 1177 | | - SC301IOT->cur_mode = mode; |
|---|
| 1177 | + sc301iot->cur_mode = mode; |
|---|
| 1178 | 1178 | h_blank = mode->hts_def - mode->width; |
|---|
| 1179 | | - __v4l2_ctrl_modify_range(SC301IOT->hblank, h_blank, |
|---|
| 1179 | + __v4l2_ctrl_modify_range(sc301iot->hblank, h_blank, |
|---|
| 1180 | 1180 | h_blank, 1, h_blank); |
|---|
| 1181 | 1181 | vblank_def = mode->vts_def - mode->height; |
|---|
| 1182 | | - __v4l2_ctrl_modify_range(SC301IOT->vblank, vblank_def, |
|---|
| 1182 | + __v4l2_ctrl_modify_range(sc301iot->vblank, vblank_def, |
|---|
| 1183 | 1183 | SC301IOT_VTS_MAX - mode->height, |
|---|
| 1184 | 1184 | 1, vblank_def); |
|---|
| 1185 | | - SC301IOT->cur_fps = mode->max_fps; |
|---|
| 1186 | | - SC301IOT->cur_vts = mode->vts_def; |
|---|
| 1185 | + sc301iot->cur_fps = mode->max_fps; |
|---|
| 1186 | + sc301iot->cur_vts = mode->vts_def; |
|---|
| 1187 | 1187 | } |
|---|
| 1188 | 1188 | |
|---|
| 1189 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1189 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1190 | 1190 | |
|---|
| 1191 | 1191 | return 0; |
|---|
| 1192 | 1192 | } |
|---|
| 1193 | 1193 | |
|---|
| 1194 | | -static int SC301IOT_get_fmt(struct v4l2_subdev *sd, |
|---|
| 1194 | +static int sc301iot_get_fmt(struct v4l2_subdev *sd, |
|---|
| 1195 | 1195 | struct v4l2_subdev_pad_config *cfg, |
|---|
| 1196 | 1196 | struct v4l2_subdev_format *fmt) |
|---|
| 1197 | 1197 | { |
|---|
| 1198 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1199 | | - const struct SC301IOT_mode *mode = SC301IOT->cur_mode; |
|---|
| 1198 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1199 | + const struct sc301iot_mode *mode = sc301iot->cur_mode; |
|---|
| 1200 | 1200 | |
|---|
| 1201 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1201 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1202 | 1202 | if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { |
|---|
| 1203 | 1203 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
|---|
| 1204 | 1204 | fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad); |
|---|
| 1205 | 1205 | #else |
|---|
| 1206 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1206 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1207 | 1207 | return -ENOTTY; |
|---|
| 1208 | 1208 | #endif |
|---|
| 1209 | 1209 | } else { |
|---|
| .. | .. |
|---|
| 1217 | 1217 | else |
|---|
| 1218 | 1218 | fmt->reserved[0] = mode->vc[PAD0]; |
|---|
| 1219 | 1219 | } |
|---|
| 1220 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1220 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1221 | 1221 | return 0; |
|---|
| 1222 | 1222 | } |
|---|
| 1223 | 1223 | |
|---|
| 1224 | | -static int SC301IOT_enum_mbus_code(struct v4l2_subdev *sd, |
|---|
| 1224 | +static int sc301iot_enum_mbus_code(struct v4l2_subdev *sd, |
|---|
| 1225 | 1225 | struct v4l2_subdev_pad_config *cfg, |
|---|
| 1226 | 1226 | struct v4l2_subdev_mbus_code_enum *code) |
|---|
| 1227 | 1227 | { |
|---|
| 1228 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1228 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1229 | 1229 | |
|---|
| 1230 | 1230 | if (code->index != 0) |
|---|
| 1231 | 1231 | return -EINVAL; |
|---|
| 1232 | | - code->code = SC301IOT->cur_mode->bus_fmt; |
|---|
| 1232 | + code->code = sc301iot->cur_mode->bus_fmt; |
|---|
| 1233 | 1233 | |
|---|
| 1234 | 1234 | return 0; |
|---|
| 1235 | 1235 | } |
|---|
| 1236 | 1236 | |
|---|
| 1237 | | -static int SC301IOT_enum_frame_sizes(struct v4l2_subdev *sd, |
|---|
| 1237 | +static int sc301iot_enum_frame_sizes(struct v4l2_subdev *sd, |
|---|
| 1238 | 1238 | struct v4l2_subdev_pad_config *cfg, |
|---|
| 1239 | 1239 | struct v4l2_subdev_frame_size_enum *fse) |
|---|
| 1240 | 1240 | { |
|---|
| .. | .. |
|---|
| 1252 | 1252 | return 0; |
|---|
| 1253 | 1253 | } |
|---|
| 1254 | 1254 | |
|---|
| 1255 | | -static int SC301IOT_enable_test_pattern(struct SC301IOT *SC301IOT, u32 pattern) |
|---|
| 1255 | +static int sc301iot_enable_test_pattern(struct sc301iot *sc301iot, u32 pattern) |
|---|
| 1256 | 1256 | { |
|---|
| 1257 | 1257 | u32 val = 0; |
|---|
| 1258 | 1258 | int ret = 0; |
|---|
| 1259 | 1259 | |
|---|
| 1260 | | - ret = SC301IOT_read_reg(SC301IOT->client, SC301IOT_REG_TEST_PATTERN, |
|---|
| 1260 | + ret = sc301iot_read_reg(sc301iot->client, SC301IOT_REG_TEST_PATTERN, |
|---|
| 1261 | 1261 | SC301IOT_REG_VALUE_08BIT, &val); |
|---|
| 1262 | 1262 | if (pattern) |
|---|
| 1263 | 1263 | val |= SC301IOT_TEST_PATTERN_BIT_MASK; |
|---|
| 1264 | 1264 | else |
|---|
| 1265 | 1265 | val &= ~SC301IOT_TEST_PATTERN_BIT_MASK; |
|---|
| 1266 | 1266 | |
|---|
| 1267 | | - ret |= SC301IOT_write_reg(SC301IOT->client, SC301IOT_REG_TEST_PATTERN, |
|---|
| 1267 | + ret |= sc301iot_write_reg(sc301iot->client, SC301IOT_REG_TEST_PATTERN, |
|---|
| 1268 | 1268 | SC301IOT_REG_VALUE_08BIT, val); |
|---|
| 1269 | 1269 | return ret; |
|---|
| 1270 | 1270 | } |
|---|
| 1271 | 1271 | |
|---|
| 1272 | | -static int SC301IOT_g_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1272 | +static int sc301iot_g_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1273 | 1273 | struct v4l2_subdev_frame_interval *fi) |
|---|
| 1274 | 1274 | { |
|---|
| 1275 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1276 | | - const struct SC301IOT_mode *mode = SC301IOT->cur_mode; |
|---|
| 1275 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1276 | + const struct sc301iot_mode *mode = sc301iot->cur_mode; |
|---|
| 1277 | 1277 | |
|---|
| 1278 | | - if (SC301IOT->streaming) |
|---|
| 1279 | | - fi->interval = SC301IOT->cur_fps; |
|---|
| 1278 | + if (sc301iot->streaming) |
|---|
| 1279 | + fi->interval = sc301iot->cur_fps; |
|---|
| 1280 | 1280 | else |
|---|
| 1281 | 1281 | fi->interval = mode->max_fps; |
|---|
| 1282 | 1282 | |
|---|
| 1283 | 1283 | return 0; |
|---|
| 1284 | 1284 | } |
|---|
| 1285 | 1285 | |
|---|
| 1286 | | -static int SC301IOT_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id, |
|---|
| 1286 | +static int sc301iot_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id, |
|---|
| 1287 | 1287 | struct v4l2_mbus_config *config) |
|---|
| 1288 | 1288 | { |
|---|
| 1289 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1290 | | - const struct SC301IOT_mode *mode = SC301IOT->cur_mode; |
|---|
| 1289 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1290 | + const struct sc301iot_mode *mode = sc301iot->cur_mode; |
|---|
| 1291 | 1291 | u32 val = 1 << (SC301IOT_LANES - 1) | |
|---|
| 1292 | 1292 | V4L2_MBUS_CSI2_CHANNEL_0 | |
|---|
| 1293 | 1293 | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; |
|---|
| .. | .. |
|---|
| 1303 | 1303 | return 0; |
|---|
| 1304 | 1304 | } |
|---|
| 1305 | 1305 | |
|---|
| 1306 | | -static void SC301IOT_get_module_inf(struct SC301IOT *SC301IOT, |
|---|
| 1306 | +static void sc301iot_get_module_inf(struct sc301iot *sc301iot, |
|---|
| 1307 | 1307 | struct rkmodule_inf *inf) |
|---|
| 1308 | 1308 | { |
|---|
| 1309 | 1309 | memset(inf, 0, sizeof(*inf)); |
|---|
| 1310 | 1310 | strscpy(inf->base.sensor, SC301IOT_NAME, sizeof(inf->base.sensor)); |
|---|
| 1311 | | - strscpy(inf->base.module, SC301IOT->module_name, |
|---|
| 1311 | + strscpy(inf->base.module, sc301iot->module_name, |
|---|
| 1312 | 1312 | sizeof(inf->base.module)); |
|---|
| 1313 | | - strscpy(inf->base.lens, SC301IOT->len_name, sizeof(inf->base.lens)); |
|---|
| 1313 | + strscpy(inf->base.lens, sc301iot->len_name, sizeof(inf->base.lens)); |
|---|
| 1314 | 1314 | } |
|---|
| 1315 | 1315 | |
|---|
| 1316 | | -static int SC301IOT_get_channel_info(struct SC301IOT *SC301IOT, |
|---|
| 1316 | +static int sc301iot_get_channel_info(struct sc301iot *sc301iot, |
|---|
| 1317 | 1317 | struct rkmodule_channel_info *ch_info) |
|---|
| 1318 | 1318 | { |
|---|
| 1319 | 1319 | if (ch_info->index < PAD0 || ch_info->index >= PAD_MAX) |
|---|
| 1320 | 1320 | return -EINVAL; |
|---|
| 1321 | | - ch_info->vc = SC301IOT->cur_mode->vc[ch_info->index]; |
|---|
| 1322 | | - ch_info->width = SC301IOT->cur_mode->width; |
|---|
| 1323 | | - ch_info->height = SC301IOT->cur_mode->height; |
|---|
| 1324 | | - ch_info->bus_fmt = SC301IOT->cur_mode->bus_fmt; |
|---|
| 1321 | + ch_info->vc = sc301iot->cur_mode->vc[ch_info->index]; |
|---|
| 1322 | + ch_info->width = sc301iot->cur_mode->width; |
|---|
| 1323 | + ch_info->height = sc301iot->cur_mode->height; |
|---|
| 1324 | + ch_info->bus_fmt = sc301iot->cur_mode->bus_fmt; |
|---|
| 1325 | 1325 | return 0; |
|---|
| 1326 | 1326 | } |
|---|
| 1327 | 1327 | |
|---|
| 1328 | | -static long SC301IOT_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
|---|
| 1328 | +static long sc301iot_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
|---|
| 1329 | 1329 | { |
|---|
| 1330 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1330 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1331 | 1331 | struct rkmodule_hdr_cfg *hdr; |
|---|
| 1332 | 1332 | struct rkmodule_channel_info *ch_info; |
|---|
| 1333 | 1333 | u32 i, h, w; |
|---|
| .. | .. |
|---|
| 1337 | 1337 | |
|---|
| 1338 | 1338 | switch (cmd) { |
|---|
| 1339 | 1339 | case RKMODULE_GET_MODULE_INFO: |
|---|
| 1340 | | - SC301IOT_get_module_inf(SC301IOT, (struct rkmodule_inf *)arg); |
|---|
| 1340 | + sc301iot_get_module_inf(sc301iot, (struct rkmodule_inf *)arg); |
|---|
| 1341 | 1341 | break; |
|---|
| 1342 | 1342 | case RKMODULE_GET_HDR_CFG: |
|---|
| 1343 | 1343 | hdr = (struct rkmodule_hdr_cfg *)arg; |
|---|
| 1344 | 1344 | hdr->esp.mode = HDR_NORMAL_VC; |
|---|
| 1345 | | - hdr->hdr_mode = SC301IOT->cur_mode->hdr_mode; |
|---|
| 1345 | + hdr->hdr_mode = sc301iot->cur_mode->hdr_mode; |
|---|
| 1346 | 1346 | break; |
|---|
| 1347 | 1347 | case RKMODULE_SET_HDR_CFG: |
|---|
| 1348 | 1348 | hdr = (struct rkmodule_hdr_cfg *)arg; |
|---|
| 1349 | | - w = SC301IOT->cur_mode->width; |
|---|
| 1350 | | - h = SC301IOT->cur_mode->height; |
|---|
| 1349 | + w = sc301iot->cur_mode->width; |
|---|
| 1350 | + h = sc301iot->cur_mode->height; |
|---|
| 1351 | 1351 | for (i = 0; i < ARRAY_SIZE(supported_modes); i++) { |
|---|
| 1352 | 1352 | if (w == supported_modes[i].width && |
|---|
| 1353 | 1353 | h == supported_modes[i].height && |
|---|
| 1354 | 1354 | supported_modes[i].hdr_mode == hdr->hdr_mode) { |
|---|
| 1355 | | - SC301IOT->cur_mode = &supported_modes[i]; |
|---|
| 1355 | + sc301iot->cur_mode = &supported_modes[i]; |
|---|
| 1356 | 1356 | break; |
|---|
| 1357 | 1357 | } |
|---|
| 1358 | 1358 | } |
|---|
| 1359 | 1359 | if (i == ARRAY_SIZE(supported_modes)) { |
|---|
| 1360 | | - dev_err(&SC301IOT->client->dev, |
|---|
| 1360 | + dev_err(&sc301iot->client->dev, |
|---|
| 1361 | 1361 | "not find hdr mode:%d %dx%d config\n", |
|---|
| 1362 | 1362 | hdr->hdr_mode, w, h); |
|---|
| 1363 | 1363 | ret = -EINVAL; |
|---|
| 1364 | 1364 | } else { |
|---|
| 1365 | | - w = SC301IOT->cur_mode->hts_def - SC301IOT->cur_mode->width; |
|---|
| 1366 | | - h = SC301IOT->cur_mode->vts_def - SC301IOT->cur_mode->height; |
|---|
| 1367 | | - __v4l2_ctrl_modify_range(SC301IOT->hblank, w, w, 1, w); |
|---|
| 1368 | | - __v4l2_ctrl_modify_range(SC301IOT->vblank, |
|---|
| 1365 | + w = sc301iot->cur_mode->hts_def - sc301iot->cur_mode->width; |
|---|
| 1366 | + h = sc301iot->cur_mode->vts_def - sc301iot->cur_mode->height; |
|---|
| 1367 | + __v4l2_ctrl_modify_range(sc301iot->hblank, w, w, 1, w); |
|---|
| 1368 | + __v4l2_ctrl_modify_range(sc301iot->vblank, |
|---|
| 1369 | 1369 | h, |
|---|
| 1370 | | - SC301IOT_VTS_MAX - SC301IOT->cur_mode->height, 1, h); |
|---|
| 1371 | | - SC301IOT->cur_fps = SC301IOT->cur_mode->max_fps; |
|---|
| 1372 | | - SC301IOT->cur_vts = SC301IOT->cur_mode->vts_def; |
|---|
| 1370 | + SC301IOT_VTS_MAX - sc301iot->cur_mode->height, 1, h); |
|---|
| 1371 | + sc301iot->cur_fps = sc301iot->cur_mode->max_fps; |
|---|
| 1372 | + sc301iot->cur_vts = sc301iot->cur_mode->vts_def; |
|---|
| 1373 | 1373 | } |
|---|
| 1374 | 1374 | break; |
|---|
| 1375 | 1375 | case PREISP_CMD_SET_HDRAE_EXP: |
|---|
| 1376 | | - SC301IOT_set_hdrae(SC301IOT, arg); |
|---|
| 1376 | + sc301iot_set_hdrae(sc301iot, arg); |
|---|
| 1377 | 1377 | break; |
|---|
| 1378 | 1378 | case RKMODULE_SET_QUICK_STREAM: |
|---|
| 1379 | 1379 | |
|---|
| 1380 | 1380 | stream = *((u32 *)arg); |
|---|
| 1381 | 1381 | |
|---|
| 1382 | 1382 | if (stream) |
|---|
| 1383 | | - ret = SC301IOT_write_reg(SC301IOT->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1383 | + ret = sc301iot_write_reg(sc301iot->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1384 | 1384 | SC301IOT_REG_VALUE_08BIT, SC301IOT_MODE_STREAMING); |
|---|
| 1385 | 1385 | else |
|---|
| 1386 | | - ret = SC301IOT_write_reg(SC301IOT->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1386 | + ret = sc301iot_write_reg(sc301iot->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1387 | 1387 | SC301IOT_REG_VALUE_08BIT, SC301IOT_MODE_SW_STANDBY); |
|---|
| 1388 | 1388 | break; |
|---|
| 1389 | 1389 | case RKMODULE_GET_SYNC_MODE: |
|---|
| 1390 | | - *((u32 *)arg) = SC301IOT->sync_mode; |
|---|
| 1390 | + *((u32 *)arg) = sc301iot->sync_mode; |
|---|
| 1391 | 1391 | break; |
|---|
| 1392 | 1392 | case RKMODULE_SET_SYNC_MODE: |
|---|
| 1393 | 1393 | sync_mode = *((u32 *)arg); |
|---|
| 1394 | 1394 | if (sync_mode > 3) |
|---|
| 1395 | 1395 | break; |
|---|
| 1396 | | - SC301IOT->sync_mode = sync_mode; |
|---|
| 1397 | | - dev_info(&SC301IOT->client->dev, "sync_mode = [%u]\n", SC301IOT->sync_mode); |
|---|
| 1396 | + sc301iot->sync_mode = sync_mode; |
|---|
| 1397 | + dev_info(&sc301iot->client->dev, "sync_mode = [%u]\n", sc301iot->sync_mode); |
|---|
| 1398 | 1398 | break; |
|---|
| 1399 | 1399 | case RKMODULE_GET_CHANNEL_INFO: |
|---|
| 1400 | 1400 | ch_info = (struct rkmodule_channel_info *)arg; |
|---|
| 1401 | | - ret = SC301IOT_get_channel_info(SC301IOT, ch_info); |
|---|
| 1401 | + ret = sc301iot_get_channel_info(sc301iot, ch_info); |
|---|
| 1402 | 1402 | break; |
|---|
| 1403 | 1403 | default: |
|---|
| 1404 | 1404 | ret = -ENOIOCTLCMD; |
|---|
| .. | .. |
|---|
| 1409 | 1409 | } |
|---|
| 1410 | 1410 | |
|---|
| 1411 | 1411 | #ifdef CONFIG_COMPAT |
|---|
| 1412 | | -static long SC301IOT_compat_ioctl32(struct v4l2_subdev *sd, |
|---|
| 1412 | +static long sc301iot_compat_ioctl32(struct v4l2_subdev *sd, |
|---|
| 1413 | 1413 | unsigned int cmd, unsigned long arg) |
|---|
| 1414 | 1414 | { |
|---|
| 1415 | 1415 | void __user *up = compat_ptr(arg); |
|---|
| .. | .. |
|---|
| 1429 | 1429 | return ret; |
|---|
| 1430 | 1430 | } |
|---|
| 1431 | 1431 | |
|---|
| 1432 | | - ret = SC301IOT_ioctl(sd, cmd, inf); |
|---|
| 1432 | + ret = sc301iot_ioctl(sd, cmd, inf); |
|---|
| 1433 | 1433 | if (!ret) { |
|---|
| 1434 | 1434 | if (copy_to_user(up, inf, sizeof(*inf))) { |
|---|
| 1435 | 1435 | kfree(inf); |
|---|
| .. | .. |
|---|
| 1448 | 1448 | kfree(cfg); |
|---|
| 1449 | 1449 | return -EFAULT; |
|---|
| 1450 | 1450 | } |
|---|
| 1451 | | - ret = SC301IOT_ioctl(sd, cmd, cfg); |
|---|
| 1451 | + ret = sc301iot_ioctl(sd, cmd, cfg); |
|---|
| 1452 | 1452 | kfree(cfg); |
|---|
| 1453 | 1453 | break; |
|---|
| 1454 | 1454 | case RKMODULE_GET_HDR_CFG: |
|---|
| .. | .. |
|---|
| 1458 | 1458 | return ret; |
|---|
| 1459 | 1459 | } |
|---|
| 1460 | 1460 | |
|---|
| 1461 | | - ret = SC301IOT_ioctl(sd, cmd, hdr); |
|---|
| 1461 | + ret = sc301iot_ioctl(sd, cmd, hdr); |
|---|
| 1462 | 1462 | if (!ret) { |
|---|
| 1463 | 1463 | if (copy_to_user(up, hdr, sizeof(*hdr))) { |
|---|
| 1464 | 1464 | kfree(hdr); |
|---|
| .. | .. |
|---|
| 1477 | 1477 | kfree(hdr); |
|---|
| 1478 | 1478 | return -EFAULT; |
|---|
| 1479 | 1479 | } |
|---|
| 1480 | | - ret = SC301IOT_ioctl(sd, cmd, hdr); |
|---|
| 1480 | + ret = sc301iot_ioctl(sd, cmd, hdr); |
|---|
| 1481 | 1481 | kfree(hdr); |
|---|
| 1482 | 1482 | break; |
|---|
| 1483 | 1483 | case PREISP_CMD_SET_HDRAE_EXP: |
|---|
| .. | .. |
|---|
| 1490 | 1490 | kfree(hdrae); |
|---|
| 1491 | 1491 | return -EFAULT; |
|---|
| 1492 | 1492 | } |
|---|
| 1493 | | - ret = SC301IOT_ioctl(sd, cmd, hdrae); |
|---|
| 1493 | + ret = sc301iot_ioctl(sd, cmd, hdrae); |
|---|
| 1494 | 1494 | kfree(hdrae); |
|---|
| 1495 | 1495 | break; |
|---|
| 1496 | 1496 | case RKMODULE_SET_QUICK_STREAM: |
|---|
| 1497 | 1497 | if (copy_from_user(&stream, up, sizeof(u32))) |
|---|
| 1498 | 1498 | return -EFAULT; |
|---|
| 1499 | | - ret = SC301IOT_ioctl(sd, cmd, &stream); |
|---|
| 1499 | + ret = sc301iot_ioctl(sd, cmd, &stream); |
|---|
| 1500 | 1500 | break; |
|---|
| 1501 | 1501 | case RKMODULE_GET_CHANNEL_INFO: |
|---|
| 1502 | 1502 | ch_info = kzalloc(sizeof(*ch_info), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 1505 | 1505 | return ret; |
|---|
| 1506 | 1506 | } |
|---|
| 1507 | 1507 | |
|---|
| 1508 | | - ret = SC301IOT_ioctl(sd, cmd, ch_info); |
|---|
| 1508 | + ret = sc301iot_ioctl(sd, cmd, ch_info); |
|---|
| 1509 | 1509 | if (!ret) { |
|---|
| 1510 | 1510 | ret = copy_to_user(up, ch_info, sizeof(*ch_info)); |
|---|
| 1511 | 1511 | if (ret) |
|---|
| .. | .. |
|---|
| 1522 | 1522 | } |
|---|
| 1523 | 1523 | #endif |
|---|
| 1524 | 1524 | |
|---|
| 1525 | | -static int SC301IOT_s_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1525 | +static int sc301iot_s_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1526 | 1526 | struct v4l2_subdev_frame_interval *fi) |
|---|
| 1527 | 1527 | { |
|---|
| 1528 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1528 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1529 | 1529 | struct device *dev = sd->dev; |
|---|
| 1530 | 1530 | int ret = -1; |
|---|
| 1531 | 1531 | s64 vblank_def; |
|---|
| .. | .. |
|---|
| 1534 | 1534 | fps_set = DIV_ROUND_CLOSEST(fi->interval.denominator, fi->interval.numerator); |
|---|
| 1535 | 1535 | dev_info(dev, "%s set fps = %u\n", __func__, fps_set); |
|---|
| 1536 | 1536 | |
|---|
| 1537 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1537 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1538 | 1538 | |
|---|
| 1539 | | - current_fps = DIV_ROUND_CLOSEST(SC301IOT->cur_mode->max_fps.denominator, |
|---|
| 1540 | | - SC301IOT->cur_mode->max_fps.numerator); |
|---|
| 1541 | | - vblank_def = SC301IOT->cur_mode->vts_def * current_fps / fps_set - |
|---|
| 1542 | | - SC301IOT->cur_mode->height; |
|---|
| 1543 | | - if (SC301IOT->sync_mode == SLAVE_MODE) |
|---|
| 1539 | + current_fps = DIV_ROUND_CLOSEST(sc301iot->cur_mode->max_fps.denominator, |
|---|
| 1540 | + sc301iot->cur_mode->max_fps.numerator); |
|---|
| 1541 | + vblank_def = sc301iot->cur_mode->vts_def * current_fps / fps_set - |
|---|
| 1542 | + sc301iot->cur_mode->height; |
|---|
| 1543 | + if (sc301iot->sync_mode == SLAVE_MODE) |
|---|
| 1544 | 1544 | vblank_def -= 3; // adjust vts |
|---|
| 1545 | | - ret = __v4l2_ctrl_s_ctrl(SC301IOT->vblank, vblank_def); |
|---|
| 1546 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1545 | + ret = __v4l2_ctrl_s_ctrl(sc301iot->vblank, vblank_def); |
|---|
| 1546 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1547 | 1547 | if (ret < 0) |
|---|
| 1548 | 1548 | dev_err(dev, "%s __v4l2_ctrl_s_ctrl error - %d\n", __func__, ret); |
|---|
| 1549 | 1549 | return ret; |
|---|
| 1550 | 1550 | } |
|---|
| 1551 | 1551 | |
|---|
| 1552 | | -static int __SC301IOT_start_stream(struct SC301IOT *SC301IOT) |
|---|
| 1552 | +static int __sc301iot_start_stream(struct sc301iot *sc301iot) |
|---|
| 1553 | 1553 | { |
|---|
| 1554 | 1554 | int ret; |
|---|
| 1555 | 1555 | |
|---|
| 1556 | | - if (!SC301IOT->is_thunderboot) { |
|---|
| 1557 | | - ret = SC301IOT_write_array(SC301IOT->client, SC301IOT->cur_mode->reg_list); |
|---|
| 1556 | + if (!sc301iot->is_thunderboot) { |
|---|
| 1557 | + ret = sc301iot_write_array(sc301iot->client, sc301iot->cur_mode->reg_list); |
|---|
| 1558 | 1558 | if (ret) |
|---|
| 1559 | 1559 | return ret; |
|---|
| 1560 | 1560 | |
|---|
| 1561 | 1561 | /* In case these controls are set before streaming */ |
|---|
| 1562 | | - ret = __v4l2_ctrl_handler_setup(&SC301IOT->ctrl_handler); |
|---|
| 1562 | + ret = __v4l2_ctrl_handler_setup(&sc301iot->ctrl_handler); |
|---|
| 1563 | 1563 | if (ret) |
|---|
| 1564 | 1564 | return ret; |
|---|
| 1565 | | - if (SC301IOT->has_init_exp && SC301IOT->cur_mode->hdr_mode != NO_HDR) { |
|---|
| 1566 | | - ret = SC301IOT_ioctl(&SC301IOT->subdev, PREISP_CMD_SET_HDRAE_EXP, |
|---|
| 1567 | | - &SC301IOT->init_hdrae_exp); |
|---|
| 1565 | + if (sc301iot->has_init_exp && sc301iot->cur_mode->hdr_mode != NO_HDR) { |
|---|
| 1566 | + ret = sc301iot_ioctl(&sc301iot->subdev, PREISP_CMD_SET_HDRAE_EXP, |
|---|
| 1567 | + &sc301iot->init_hdrae_exp); |
|---|
| 1568 | 1568 | if (ret) { |
|---|
| 1569 | | - dev_err(&SC301IOT->client->dev, |
|---|
| 1569 | + dev_err(&sc301iot->client->dev, |
|---|
| 1570 | 1570 | "init exp fail in hdr mode\n"); |
|---|
| 1571 | 1571 | return ret; |
|---|
| 1572 | 1572 | } |
|---|
| 1573 | 1573 | } |
|---|
| 1574 | 1574 | |
|---|
| 1575 | | - if (SC301IOT->sync_mode == SLAVE_MODE) { |
|---|
| 1576 | | - SC301IOT_write_reg(SC301IOT->client, 0x3222, |
|---|
| 1575 | + if (sc301iot->sync_mode == SLAVE_MODE) { |
|---|
| 1576 | + sc301iot_write_reg(sc301iot->client, 0x3222, |
|---|
| 1577 | 1577 | SC301IOT_REG_VALUE_08BIT, 0x01); |
|---|
| 1578 | | - SC301IOT_write_reg(SC301IOT->client, 0x3223, |
|---|
| 1578 | + sc301iot_write_reg(sc301iot->client, 0x3223, |
|---|
| 1579 | 1579 | SC301IOT_REG_VALUE_08BIT, 0xc8); |
|---|
| 1580 | | - SC301IOT_write_reg(SC301IOT->client, 0x3225, |
|---|
| 1580 | + sc301iot_write_reg(sc301iot->client, 0x3225, |
|---|
| 1581 | 1581 | SC301IOT_REG_VALUE_08BIT, 0x10); |
|---|
| 1582 | | - SC301IOT_write_reg(SC301IOT->client, 0x322e, |
|---|
| 1583 | | - SC301IOT_REG_VALUE_08BIT, (SC301IOT->cur_vts - 4) >> 8); |
|---|
| 1584 | | - SC301IOT_write_reg(SC301IOT->client, 0x322f, |
|---|
| 1585 | | - SC301IOT_REG_VALUE_08BIT, (SC301IOT->cur_vts - 4) & 0xff); |
|---|
| 1586 | | - } else if (SC301IOT->sync_mode == NO_SYNC_MODE) { |
|---|
| 1587 | | - SC301IOT_write_reg(SC301IOT->client, 0x3222, |
|---|
| 1582 | + sc301iot_write_reg(sc301iot->client, 0x322e, |
|---|
| 1583 | + SC301IOT_REG_VALUE_08BIT, (sc301iot->cur_vts - 4) >> 8); |
|---|
| 1584 | + sc301iot_write_reg(sc301iot->client, 0x322f, |
|---|
| 1585 | + SC301IOT_REG_VALUE_08BIT, (sc301iot->cur_vts - 4) & 0xff); |
|---|
| 1586 | + } else if (sc301iot->sync_mode == NO_SYNC_MODE) { |
|---|
| 1587 | + sc301iot_write_reg(sc301iot->client, 0x3222, |
|---|
| 1588 | 1588 | SC301IOT_REG_VALUE_08BIT, 0x00); |
|---|
| 1589 | | - SC301IOT_write_reg(SC301IOT->client, 0x3223, |
|---|
| 1589 | + sc301iot_write_reg(sc301iot->client, 0x3223, |
|---|
| 1590 | 1590 | SC301IOT_REG_VALUE_08BIT, 0xd0); |
|---|
| 1591 | | - SC301IOT_write_reg(SC301IOT->client, 0x3225, |
|---|
| 1591 | + sc301iot_write_reg(sc301iot->client, 0x3225, |
|---|
| 1592 | 1592 | SC301IOT_REG_VALUE_08BIT, 0x00); |
|---|
| 1593 | | - SC301IOT_write_reg(SC301IOT->client, 0x322e, |
|---|
| 1593 | + sc301iot_write_reg(sc301iot->client, 0x322e, |
|---|
| 1594 | 1594 | SC301IOT_REG_VALUE_08BIT, 0x00); |
|---|
| 1595 | | - SC301IOT_write_reg(SC301IOT->client, 0x322f, |
|---|
| 1595 | + sc301iot_write_reg(sc301iot->client, 0x322f, |
|---|
| 1596 | 1596 | SC301IOT_REG_VALUE_08BIT, 0x02); |
|---|
| 1597 | 1597 | } |
|---|
| 1598 | 1598 | } |
|---|
| 1599 | 1599 | |
|---|
| 1600 | | - dev_dbg(&SC301IOT->client->dev, "start stream\n"); |
|---|
| 1601 | | - return SC301IOT_write_reg(SC301IOT->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1600 | + dev_dbg(&sc301iot->client->dev, "start stream\n"); |
|---|
| 1601 | + return sc301iot_write_reg(sc301iot->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1602 | 1602 | SC301IOT_REG_VALUE_08BIT, SC301IOT_MODE_STREAMING); |
|---|
| 1603 | 1603 | } |
|---|
| 1604 | 1604 | |
|---|
| 1605 | | -static int __SC301IOT_stop_stream(struct SC301IOT *SC301IOT) |
|---|
| 1605 | +static int __sc301iot_stop_stream(struct sc301iot *sc301iot) |
|---|
| 1606 | 1606 | { |
|---|
| 1607 | | - SC301IOT->has_init_exp = false; |
|---|
| 1608 | | - dev_dbg(&SC301IOT->client->dev, "stop stream\n"); |
|---|
| 1609 | | - if (SC301IOT->is_thunderboot) |
|---|
| 1610 | | - SC301IOT->is_first_streamoff = true; |
|---|
| 1611 | | - return SC301IOT_write_reg(SC301IOT->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1607 | + sc301iot->has_init_exp = false; |
|---|
| 1608 | + dev_dbg(&sc301iot->client->dev, "stop stream\n"); |
|---|
| 1609 | + if (sc301iot->is_thunderboot) { |
|---|
| 1610 | + sc301iot->is_first_streamoff = true; |
|---|
| 1611 | + pm_runtime_put(&sc301iot->client->dev); |
|---|
| 1612 | + } |
|---|
| 1613 | + return sc301iot_write_reg(sc301iot->client, SC301IOT_REG_CTRL_MODE, |
|---|
| 1612 | 1614 | SC301IOT_REG_VALUE_08BIT, SC301IOT_MODE_SW_STANDBY); |
|---|
| 1613 | 1615 | } |
|---|
| 1614 | 1616 | |
|---|
| 1615 | | -static int __SC301IOT_power_on(struct SC301IOT *SC301IOT); |
|---|
| 1616 | | -static int SC301IOT_s_stream(struct v4l2_subdev *sd, int on) |
|---|
| 1617 | +static int __sc301iot_power_on(struct sc301iot *sc301iot); |
|---|
| 1618 | +static int sc301iot_s_stream(struct v4l2_subdev *sd, int on) |
|---|
| 1617 | 1619 | { |
|---|
| 1618 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1619 | | - struct i2c_client *client = SC301IOT->client; |
|---|
| 1620 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1621 | + struct i2c_client *client = sc301iot->client; |
|---|
| 1620 | 1622 | int ret = 0; |
|---|
| 1621 | 1623 | |
|---|
| 1622 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1624 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1623 | 1625 | on = !!on; |
|---|
| 1624 | | - if (on == SC301IOT->streaming) |
|---|
| 1626 | + if (on == sc301iot->streaming) |
|---|
| 1625 | 1627 | goto unlock_and_return; |
|---|
| 1626 | 1628 | |
|---|
| 1627 | 1629 | if (on) { |
|---|
| 1628 | | - if (SC301IOT->is_thunderboot && rkisp_tb_get_state() == RKISP_TB_NG) { |
|---|
| 1629 | | - SC301IOT->is_thunderboot = false; |
|---|
| 1630 | | - __SC301IOT_power_on(SC301IOT); |
|---|
| 1630 | + if (sc301iot->is_thunderboot && rkisp_tb_get_state() == RKISP_TB_NG) { |
|---|
| 1631 | + sc301iot->is_thunderboot = false; |
|---|
| 1632 | + __sc301iot_power_on(sc301iot); |
|---|
| 1631 | 1633 | } |
|---|
| 1632 | 1634 | |
|---|
| 1633 | 1635 | ret = pm_runtime_get_sync(&client->dev); |
|---|
| .. | .. |
|---|
| 1636 | 1638 | goto unlock_and_return; |
|---|
| 1637 | 1639 | } |
|---|
| 1638 | 1640 | |
|---|
| 1639 | | - ret = __SC301IOT_start_stream(SC301IOT); |
|---|
| 1641 | + ret = __sc301iot_start_stream(sc301iot); |
|---|
| 1640 | 1642 | if (ret) { |
|---|
| 1641 | 1643 | v4l2_err(sd, "start stream failed while write regs\n"); |
|---|
| 1642 | 1644 | pm_runtime_put(&client->dev); |
|---|
| 1643 | 1645 | goto unlock_and_return; |
|---|
| 1644 | 1646 | } |
|---|
| 1645 | 1647 | } else { |
|---|
| 1646 | | - __SC301IOT_stop_stream(SC301IOT); |
|---|
| 1648 | + __sc301iot_stop_stream(sc301iot); |
|---|
| 1647 | 1649 | pm_runtime_put(&client->dev); |
|---|
| 1648 | 1650 | } |
|---|
| 1649 | 1651 | |
|---|
| 1650 | | - SC301IOT->streaming = on; |
|---|
| 1652 | + sc301iot->streaming = on; |
|---|
| 1651 | 1653 | |
|---|
| 1652 | 1654 | unlock_and_return: |
|---|
| 1653 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1655 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1654 | 1656 | |
|---|
| 1655 | 1657 | return ret; |
|---|
| 1656 | 1658 | } |
|---|
| 1657 | 1659 | |
|---|
| 1658 | | -static int SC301IOT_s_power(struct v4l2_subdev *sd, int on) |
|---|
| 1660 | +static int sc301iot_s_power(struct v4l2_subdev *sd, int on) |
|---|
| 1659 | 1661 | { |
|---|
| 1660 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1661 | | - struct i2c_client *client = SC301IOT->client; |
|---|
| 1662 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1663 | + struct i2c_client *client = sc301iot->client; |
|---|
| 1662 | 1664 | int ret = 0; |
|---|
| 1663 | 1665 | |
|---|
| 1664 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1666 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1665 | 1667 | |
|---|
| 1666 | 1668 | /* If the power state is not modified - no work to do. */ |
|---|
| 1667 | | - if (SC301IOT->power_on == !!on) |
|---|
| 1669 | + if (sc301iot->power_on == !!on) |
|---|
| 1668 | 1670 | goto unlock_and_return; |
|---|
| 1669 | 1671 | |
|---|
| 1670 | 1672 | if (on) { |
|---|
| .. | .. |
|---|
| 1674 | 1676 | goto unlock_and_return; |
|---|
| 1675 | 1677 | } |
|---|
| 1676 | 1678 | |
|---|
| 1677 | | - if (!SC301IOT->is_thunderboot) { |
|---|
| 1678 | | - ret = SC301IOT_write_array(SC301IOT->client, SC301IOT_global_regs); |
|---|
| 1679 | + if (!sc301iot->is_thunderboot) { |
|---|
| 1680 | + ret = sc301iot_write_array(sc301iot->client, sc301iot_global_regs); |
|---|
| 1679 | 1681 | if (ret) { |
|---|
| 1680 | 1682 | v4l2_err(sd, "could not set init registers\n"); |
|---|
| 1681 | 1683 | pm_runtime_put_noidle(&client->dev); |
|---|
| .. | .. |
|---|
| 1683 | 1685 | } |
|---|
| 1684 | 1686 | } |
|---|
| 1685 | 1687 | |
|---|
| 1686 | | - SC301IOT->power_on = true; |
|---|
| 1688 | + sc301iot->power_on = true; |
|---|
| 1687 | 1689 | } else { |
|---|
| 1688 | 1690 | pm_runtime_put(&client->dev); |
|---|
| 1689 | | - SC301IOT->power_on = false; |
|---|
| 1691 | + sc301iot->power_on = false; |
|---|
| 1690 | 1692 | } |
|---|
| 1691 | 1693 | |
|---|
| 1692 | 1694 | unlock_and_return: |
|---|
| 1693 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1695 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1694 | 1696 | |
|---|
| 1695 | 1697 | return ret; |
|---|
| 1696 | 1698 | } |
|---|
| 1697 | 1699 | |
|---|
| 1698 | 1700 | /* Calculate the delay in us by clock rate and clock cycles */ |
|---|
| 1699 | | -static inline u32 SC301IOT_cal_delay(u32 cycles) |
|---|
| 1701 | +static inline u32 sc301iot_cal_delay(u32 cycles) |
|---|
| 1700 | 1702 | { |
|---|
| 1701 | 1703 | return DIV_ROUND_UP(cycles, SC301IOT_XVCLK_FREQ / 1000 / 1000); |
|---|
| 1702 | 1704 | } |
|---|
| 1703 | 1705 | |
|---|
| 1704 | | -static int __SC301IOT_power_on(struct SC301IOT *SC301IOT) |
|---|
| 1706 | +static int __sc301iot_power_on(struct sc301iot *sc301iot) |
|---|
| 1705 | 1707 | { |
|---|
| 1706 | 1708 | int ret; |
|---|
| 1707 | 1709 | u32 delay_us; |
|---|
| 1708 | | - struct device *dev = &SC301IOT->client->dev; |
|---|
| 1710 | + struct device *dev = &sc301iot->client->dev; |
|---|
| 1709 | 1711 | |
|---|
| 1710 | | - if (!IS_ERR_OR_NULL(SC301IOT->pins_default)) { |
|---|
| 1711 | | - ret = pinctrl_select_state(SC301IOT->pinctrl, |
|---|
| 1712 | | - SC301IOT->pins_default); |
|---|
| 1712 | + if (!IS_ERR_OR_NULL(sc301iot->pins_default)) { |
|---|
| 1713 | + ret = pinctrl_select_state(sc301iot->pinctrl, |
|---|
| 1714 | + sc301iot->pins_default); |
|---|
| 1713 | 1715 | if (ret < 0) |
|---|
| 1714 | 1716 | dev_err(dev, "could not set pins\n"); |
|---|
| 1715 | 1717 | } |
|---|
| 1716 | | - ret = clk_set_rate(SC301IOT->xvclk, SC301IOT_XVCLK_FREQ); |
|---|
| 1718 | + ret = clk_set_rate(sc301iot->xvclk, SC301IOT_XVCLK_FREQ); |
|---|
| 1717 | 1719 | if (ret < 0) |
|---|
| 1718 | 1720 | dev_warn(dev, "Failed to set xvclk rate (24MHz)\n"); |
|---|
| 1719 | | - if (clk_get_rate(SC301IOT->xvclk) != SC301IOT_XVCLK_FREQ) |
|---|
| 1721 | + if (clk_get_rate(sc301iot->xvclk) != SC301IOT_XVCLK_FREQ) |
|---|
| 1720 | 1722 | dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n"); |
|---|
| 1721 | | - ret = clk_prepare_enable(SC301IOT->xvclk); |
|---|
| 1723 | + ret = clk_prepare_enable(sc301iot->xvclk); |
|---|
| 1722 | 1724 | if (ret < 0) { |
|---|
| 1723 | 1725 | dev_err(dev, "Failed to enable xvclk\n"); |
|---|
| 1724 | 1726 | goto disable_clk; |
|---|
| 1725 | 1727 | } |
|---|
| 1726 | | - if (SC301IOT->is_thunderboot) |
|---|
| 1728 | + if (sc301iot->is_thunderboot) |
|---|
| 1727 | 1729 | return 0; |
|---|
| 1728 | | - if (!IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 1729 | | - gpiod_set_value_cansleep(SC301IOT->reset_gpio, 0); |
|---|
| 1730 | + if (!IS_ERR(sc301iot->reset_gpio)) |
|---|
| 1731 | + gpiod_set_value_cansleep(sc301iot->reset_gpio, 0); |
|---|
| 1730 | 1732 | |
|---|
| 1731 | | - ret = regulator_bulk_enable(SC301IOT_NUM_SUPPLIES, SC301IOT->supplies); |
|---|
| 1733 | + ret = regulator_bulk_enable(SC301IOT_NUM_SUPPLIES, sc301iot->supplies); |
|---|
| 1732 | 1734 | if (ret < 0) { |
|---|
| 1733 | 1735 | dev_err(dev, "Failed to enable regulators\n"); |
|---|
| 1734 | 1736 | goto disable_clk; |
|---|
| 1735 | 1737 | } |
|---|
| 1736 | | - if (!IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 1737 | | - gpiod_set_value_cansleep(SC301IOT->reset_gpio, 1); |
|---|
| 1738 | + if (!IS_ERR(sc301iot->reset_gpio)) |
|---|
| 1739 | + gpiod_set_value_cansleep(sc301iot->reset_gpio, 1); |
|---|
| 1738 | 1740 | |
|---|
| 1739 | 1741 | usleep_range(500, 1000); |
|---|
| 1740 | | - if (!IS_ERR(SC301IOT->pwdn_gpio)) |
|---|
| 1741 | | - gpiod_set_value_cansleep(SC301IOT->pwdn_gpio, 1); |
|---|
| 1742 | + if (!IS_ERR(sc301iot->pwdn_gpio)) |
|---|
| 1743 | + gpiod_set_value_cansleep(sc301iot->pwdn_gpio, 1); |
|---|
| 1742 | 1744 | usleep_range(4500, 5000); |
|---|
| 1743 | 1745 | |
|---|
| 1744 | | - if (!IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 1746 | + if (!IS_ERR(sc301iot->reset_gpio)) |
|---|
| 1745 | 1747 | usleep_range(6000, 8000); |
|---|
| 1746 | 1748 | else |
|---|
| 1747 | 1749 | usleep_range(12000, 16000); |
|---|
| 1748 | 1750 | |
|---|
| 1749 | 1751 | /* 8192 cycles prior to first SCCB transaction */ |
|---|
| 1750 | | - delay_us = SC301IOT_cal_delay(8192); |
|---|
| 1752 | + delay_us = sc301iot_cal_delay(8192); |
|---|
| 1751 | 1753 | usleep_range(delay_us, delay_us * 2); |
|---|
| 1752 | 1754 | |
|---|
| 1753 | 1755 | return 0; |
|---|
| 1754 | 1756 | |
|---|
| 1755 | 1757 | disable_clk: |
|---|
| 1756 | | - clk_disable_unprepare(SC301IOT->xvclk); |
|---|
| 1758 | + clk_disable_unprepare(sc301iot->xvclk); |
|---|
| 1757 | 1759 | |
|---|
| 1758 | 1760 | return ret; |
|---|
| 1759 | 1761 | } |
|---|
| 1760 | 1762 | |
|---|
| 1761 | | -static void __SC301IOT_power_off(struct SC301IOT *SC301IOT) |
|---|
| 1763 | +static void __sc301iot_power_off(struct sc301iot *sc301iot) |
|---|
| 1762 | 1764 | { |
|---|
| 1763 | 1765 | int ret; |
|---|
| 1764 | | - struct device *dev = &SC301IOT->client->dev; |
|---|
| 1766 | + struct device *dev = &sc301iot->client->dev; |
|---|
| 1765 | 1767 | |
|---|
| 1766 | | - clk_disable_unprepare(SC301IOT->xvclk); |
|---|
| 1767 | | - if (SC301IOT->is_thunderboot) { |
|---|
| 1768 | | - if (SC301IOT->is_first_streamoff) { |
|---|
| 1769 | | - SC301IOT->is_thunderboot = false; |
|---|
| 1770 | | - SC301IOT->is_first_streamoff = false; |
|---|
| 1768 | + clk_disable_unprepare(sc301iot->xvclk); |
|---|
| 1769 | + if (sc301iot->is_thunderboot) { |
|---|
| 1770 | + if (sc301iot->is_first_streamoff) { |
|---|
| 1771 | + sc301iot->is_thunderboot = false; |
|---|
| 1772 | + sc301iot->is_first_streamoff = false; |
|---|
| 1771 | 1773 | } else { |
|---|
| 1772 | 1774 | return; |
|---|
| 1773 | 1775 | } |
|---|
| 1774 | 1776 | } |
|---|
| 1775 | 1777 | |
|---|
| 1776 | | - if (!IS_ERR(SC301IOT->pwdn_gpio)) |
|---|
| 1777 | | - gpiod_set_value_cansleep(SC301IOT->pwdn_gpio, 0); |
|---|
| 1778 | | - if (!IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 1779 | | - gpiod_set_value_cansleep(SC301IOT->reset_gpio, 0); |
|---|
| 1780 | | - if (!IS_ERR_OR_NULL(SC301IOT->pins_sleep)) { |
|---|
| 1781 | | - ret = pinctrl_select_state(SC301IOT->pinctrl, |
|---|
| 1782 | | - SC301IOT->pins_sleep); |
|---|
| 1778 | + if (!IS_ERR(sc301iot->pwdn_gpio)) |
|---|
| 1779 | + gpiod_set_value_cansleep(sc301iot->pwdn_gpio, 0); |
|---|
| 1780 | + if (!IS_ERR(sc301iot->reset_gpio)) |
|---|
| 1781 | + gpiod_set_value_cansleep(sc301iot->reset_gpio, 0); |
|---|
| 1782 | + if (!IS_ERR_OR_NULL(sc301iot->pins_sleep)) { |
|---|
| 1783 | + ret = pinctrl_select_state(sc301iot->pinctrl, |
|---|
| 1784 | + sc301iot->pins_sleep); |
|---|
| 1783 | 1785 | if (ret < 0) |
|---|
| 1784 | 1786 | dev_dbg(dev, "could not set pins\n"); |
|---|
| 1785 | 1787 | } |
|---|
| 1786 | | - regulator_bulk_disable(SC301IOT_NUM_SUPPLIES, SC301IOT->supplies); |
|---|
| 1788 | + regulator_bulk_disable(SC301IOT_NUM_SUPPLIES, sc301iot->supplies); |
|---|
| 1787 | 1789 | } |
|---|
| 1788 | 1790 | |
|---|
| 1789 | | -static int SC301IOT_runtime_resume(struct device *dev) |
|---|
| 1791 | +static int sc301iot_runtime_resume(struct device *dev) |
|---|
| 1790 | 1792 | { |
|---|
| 1791 | 1793 | struct i2c_client *client = to_i2c_client(dev); |
|---|
| 1792 | 1794 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
|---|
| 1793 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1795 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1794 | 1796 | |
|---|
| 1795 | | - return __SC301IOT_power_on(SC301IOT); |
|---|
| 1797 | + return __sc301iot_power_on(sc301iot); |
|---|
| 1796 | 1798 | } |
|---|
| 1797 | 1799 | |
|---|
| 1798 | | -static int SC301IOT_runtime_suspend(struct device *dev) |
|---|
| 1800 | +static int sc301iot_runtime_suspend(struct device *dev) |
|---|
| 1799 | 1801 | { |
|---|
| 1800 | 1802 | struct i2c_client *client = to_i2c_client(dev); |
|---|
| 1801 | 1803 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
|---|
| 1802 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1804 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1803 | 1805 | |
|---|
| 1804 | | - __SC301IOT_power_off(SC301IOT); |
|---|
| 1806 | + __sc301iot_power_off(sc301iot); |
|---|
| 1805 | 1807 | |
|---|
| 1806 | 1808 | return 0; |
|---|
| 1807 | 1809 | } |
|---|
| 1808 | 1810 | |
|---|
| 1809 | 1811 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
|---|
| 1810 | | -static int SC301IOT_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) |
|---|
| 1812 | +static int sc301iot_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) |
|---|
| 1811 | 1813 | { |
|---|
| 1812 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 1814 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 1813 | 1815 | struct v4l2_mbus_framefmt *try_fmt = |
|---|
| 1814 | 1816 | v4l2_subdev_get_try_format(sd, fh->pad, 0); |
|---|
| 1815 | | - const struct SC301IOT_mode *def_mode = &supported_modes[0]; |
|---|
| 1817 | + const struct sc301iot_mode *def_mode = &supported_modes[0]; |
|---|
| 1816 | 1818 | |
|---|
| 1817 | | - mutex_lock(&SC301IOT->mutex); |
|---|
| 1819 | + mutex_lock(&sc301iot->mutex); |
|---|
| 1818 | 1820 | /* Initialize try_fmt */ |
|---|
| 1819 | 1821 | try_fmt->width = def_mode->width; |
|---|
| 1820 | 1822 | try_fmt->height = def_mode->height; |
|---|
| 1821 | 1823 | try_fmt->code = def_mode->bus_fmt; |
|---|
| 1822 | 1824 | try_fmt->field = V4L2_FIELD_NONE; |
|---|
| 1823 | 1825 | |
|---|
| 1824 | | - mutex_unlock(&SC301IOT->mutex); |
|---|
| 1826 | + mutex_unlock(&sc301iot->mutex); |
|---|
| 1825 | 1827 | /* No crop or compose */ |
|---|
| 1826 | 1828 | |
|---|
| 1827 | 1829 | return 0; |
|---|
| 1828 | 1830 | } |
|---|
| 1829 | 1831 | #endif |
|---|
| 1830 | 1832 | |
|---|
| 1831 | | -static int SC301IOT_enum_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1833 | +static int sc301iot_enum_frame_interval(struct v4l2_subdev *sd, |
|---|
| 1832 | 1834 | struct v4l2_subdev_pad_config *cfg, |
|---|
| 1833 | 1835 | struct v4l2_subdev_frame_interval_enum *fie) |
|---|
| 1834 | 1836 | { |
|---|
| .. | .. |
|---|
| 1843 | 1845 | return 0; |
|---|
| 1844 | 1846 | } |
|---|
| 1845 | 1847 | |
|---|
| 1846 | | -static const struct dev_pm_ops SC301IOT_pm_ops = { |
|---|
| 1847 | | - SET_RUNTIME_PM_OPS(SC301IOT_runtime_suspend, |
|---|
| 1848 | | - SC301IOT_runtime_resume, NULL) |
|---|
| 1848 | +static const struct dev_pm_ops sc301iot_pm_ops = { |
|---|
| 1849 | + SET_RUNTIME_PM_OPS(sc301iot_runtime_suspend, |
|---|
| 1850 | + sc301iot_runtime_resume, NULL) |
|---|
| 1849 | 1851 | }; |
|---|
| 1850 | 1852 | |
|---|
| 1851 | 1853 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
|---|
| 1852 | | -static const struct v4l2_subdev_internal_ops SC301IOT_internal_ops = { |
|---|
| 1853 | | - .open = SC301IOT_open, |
|---|
| 1854 | +static const struct v4l2_subdev_internal_ops sc301iot_internal_ops = { |
|---|
| 1855 | + .open = sc301iot_open, |
|---|
| 1854 | 1856 | }; |
|---|
| 1855 | 1857 | #endif |
|---|
| 1856 | 1858 | |
|---|
| 1857 | | -static const struct v4l2_subdev_core_ops SC301IOT_core_ops = { |
|---|
| 1858 | | - .s_power = SC301IOT_s_power, |
|---|
| 1859 | | - .ioctl = SC301IOT_ioctl, |
|---|
| 1859 | +static const struct v4l2_subdev_core_ops sc301iot_core_ops = { |
|---|
| 1860 | + .s_power = sc301iot_s_power, |
|---|
| 1861 | + .ioctl = sc301iot_ioctl, |
|---|
| 1860 | 1862 | #ifdef CONFIG_COMPAT |
|---|
| 1861 | | - .compat_ioctl32 = SC301IOT_compat_ioctl32, |
|---|
| 1863 | + .compat_ioctl32 = sc301iot_compat_ioctl32, |
|---|
| 1862 | 1864 | #endif |
|---|
| 1863 | 1865 | }; |
|---|
| 1864 | 1866 | |
|---|
| 1865 | | -static const struct v4l2_subdev_video_ops SC301IOT_video_ops = { |
|---|
| 1866 | | - .s_stream = SC301IOT_s_stream, |
|---|
| 1867 | | - .g_frame_interval = SC301IOT_g_frame_interval, |
|---|
| 1868 | | - .s_frame_interval = SC301IOT_s_frame_interval, |
|---|
| 1867 | +static const struct v4l2_subdev_video_ops sc301iot_video_ops = { |
|---|
| 1868 | + .s_stream = sc301iot_s_stream, |
|---|
| 1869 | + .g_frame_interval = sc301iot_g_frame_interval, |
|---|
| 1870 | + .s_frame_interval = sc301iot_s_frame_interval, |
|---|
| 1869 | 1871 | }; |
|---|
| 1870 | 1872 | |
|---|
| 1871 | | -static const struct v4l2_subdev_pad_ops SC301IOT_pad_ops = { |
|---|
| 1872 | | - .enum_mbus_code = SC301IOT_enum_mbus_code, |
|---|
| 1873 | | - .enum_frame_size = SC301IOT_enum_frame_sizes, |
|---|
| 1874 | | - .enum_frame_interval = SC301IOT_enum_frame_interval, |
|---|
| 1875 | | - .get_fmt = SC301IOT_get_fmt, |
|---|
| 1876 | | - .set_fmt = SC301IOT_set_fmt, |
|---|
| 1877 | | - .get_mbus_config = SC301IOT_g_mbus_config, |
|---|
| 1873 | +static const struct v4l2_subdev_pad_ops sc301iot_pad_ops = { |
|---|
| 1874 | + .enum_mbus_code = sc301iot_enum_mbus_code, |
|---|
| 1875 | + .enum_frame_size = sc301iot_enum_frame_sizes, |
|---|
| 1876 | + .enum_frame_interval = sc301iot_enum_frame_interval, |
|---|
| 1877 | + .get_fmt = sc301iot_get_fmt, |
|---|
| 1878 | + .set_fmt = sc301iot_set_fmt, |
|---|
| 1879 | + .get_mbus_config = sc301iot_g_mbus_config, |
|---|
| 1878 | 1880 | }; |
|---|
| 1879 | 1881 | |
|---|
| 1880 | | -static const struct v4l2_subdev_ops SC301IOT_subdev_ops = { |
|---|
| 1881 | | - .core = &SC301IOT_core_ops, |
|---|
| 1882 | | - .video = &SC301IOT_video_ops, |
|---|
| 1883 | | - .pad = &SC301IOT_pad_ops, |
|---|
| 1882 | +static const struct v4l2_subdev_ops sc301iot_subdev_ops = { |
|---|
| 1883 | + .core = &sc301iot_core_ops, |
|---|
| 1884 | + .video = &sc301iot_video_ops, |
|---|
| 1885 | + .pad = &sc301iot_pad_ops, |
|---|
| 1884 | 1886 | }; |
|---|
| 1885 | 1887 | |
|---|
| 1886 | | -static void SC301IOT_modify_fps_info(struct SC301IOT *SC301IOT) |
|---|
| 1888 | +static void sc301iot_modify_fps_info(struct sc301iot *sc301iot) |
|---|
| 1887 | 1889 | { |
|---|
| 1888 | | - const struct SC301IOT_mode *mode = SC301IOT->cur_mode; |
|---|
| 1890 | + const struct sc301iot_mode *mode = sc301iot->cur_mode; |
|---|
| 1889 | 1891 | |
|---|
| 1890 | | - SC301IOT->cur_fps.denominator = mode->max_fps.denominator * mode->vts_def / |
|---|
| 1891 | | - SC301IOT->cur_vts; |
|---|
| 1892 | + sc301iot->cur_fps.denominator = mode->max_fps.denominator * mode->vts_def / |
|---|
| 1893 | + sc301iot->cur_vts; |
|---|
| 1892 | 1894 | } |
|---|
| 1893 | 1895 | |
|---|
| 1894 | | -static int SC301IOT_set_ctrl(struct v4l2_ctrl *ctrl) |
|---|
| 1896 | +static int sc301iot_set_ctrl(struct v4l2_ctrl *ctrl) |
|---|
| 1895 | 1897 | { |
|---|
| 1896 | | - struct SC301IOT *SC301IOT = container_of(ctrl->handler, |
|---|
| 1897 | | - struct SC301IOT, ctrl_handler); |
|---|
| 1898 | | - struct i2c_client *client = SC301IOT->client; |
|---|
| 1898 | + struct sc301iot *sc301iot = container_of(ctrl->handler, |
|---|
| 1899 | + struct sc301iot, ctrl_handler); |
|---|
| 1900 | + struct i2c_client *client = sc301iot->client; |
|---|
| 1899 | 1901 | s64 max; |
|---|
| 1900 | 1902 | int ret = 0; |
|---|
| 1901 | 1903 | u32 val = 0; |
|---|
| .. | .. |
|---|
| 1904 | 1906 | switch (ctrl->id) { |
|---|
| 1905 | 1907 | case V4L2_CID_VBLANK: |
|---|
| 1906 | 1908 | /* Update max exposure while meeting expected vblanking */ |
|---|
| 1907 | | - max = SC301IOT->cur_mode->height + ctrl->val - 4; |
|---|
| 1908 | | - __v4l2_ctrl_modify_range(SC301IOT->exposure, |
|---|
| 1909 | | - SC301IOT->exposure->minimum, max, |
|---|
| 1910 | | - SC301IOT->exposure->step, |
|---|
| 1911 | | - SC301IOT->exposure->default_value); |
|---|
| 1909 | + max = sc301iot->cur_mode->height + ctrl->val - 4; |
|---|
| 1910 | + __v4l2_ctrl_modify_range(sc301iot->exposure, |
|---|
| 1911 | + sc301iot->exposure->minimum, max, |
|---|
| 1912 | + sc301iot->exposure->step, |
|---|
| 1913 | + sc301iot->exposure->default_value); |
|---|
| 1912 | 1914 | break; |
|---|
| 1913 | 1915 | } |
|---|
| 1914 | 1916 | |
|---|
| .. | .. |
|---|
| 1917 | 1919 | |
|---|
| 1918 | 1920 | switch (ctrl->id) { |
|---|
| 1919 | 1921 | case V4L2_CID_EXPOSURE: |
|---|
| 1920 | | - if (SC301IOT->cur_mode->hdr_mode == NO_HDR) { |
|---|
| 1922 | + if (sc301iot->cur_mode->hdr_mode == NO_HDR) { |
|---|
| 1921 | 1923 | ctrl->val = ctrl->val; |
|---|
| 1922 | 1924 | /* 4 least significant bits of expsoure are fractional part */ |
|---|
| 1923 | | - ret = SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1925 | + ret = sc301iot_write_reg(sc301iot->client, |
|---|
| 1924 | 1926 | SC301IOT_REG_EXPOSURE_H, |
|---|
| 1925 | 1927 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1926 | 1928 | SC301IOT_FETCH_EXP_H(ctrl->val)); |
|---|
| 1927 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1929 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1928 | 1930 | SC301IOT_REG_EXPOSURE_M, |
|---|
| 1929 | 1931 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1930 | 1932 | SC301IOT_FETCH_EXP_M(ctrl->val)); |
|---|
| 1931 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1933 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1932 | 1934 | SC301IOT_REG_EXPOSURE_L, |
|---|
| 1933 | 1935 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1934 | 1936 | SC301IOT_FETCH_EXP_L(ctrl->val)); |
|---|
| 1935 | 1937 | } |
|---|
| 1936 | 1938 | break; |
|---|
| 1937 | 1939 | case V4L2_CID_ANALOGUE_GAIN: |
|---|
| 1938 | | - if (SC301IOT->cur_mode->hdr_mode == NO_HDR) |
|---|
| 1939 | | - ret = SC301IOT_set_gain_reg(SC301IOT, ctrl->val, SC301IOT_LGAIN); |
|---|
| 1940 | + if (sc301iot->cur_mode->hdr_mode == NO_HDR) |
|---|
| 1941 | + ret = sc301iot_set_gain_reg(sc301iot, ctrl->val, SC301IOT_LGAIN); |
|---|
| 1940 | 1942 | break; |
|---|
| 1941 | 1943 | case V4L2_CID_VBLANK: |
|---|
| 1942 | | - ret = SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1944 | + ret = sc301iot_write_reg(sc301iot->client, |
|---|
| 1943 | 1945 | SC301IOT_REG_VTS_H, |
|---|
| 1944 | 1946 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1945 | | - (ctrl->val + SC301IOT->cur_mode->height) |
|---|
| 1947 | + (ctrl->val + sc301iot->cur_mode->height) |
|---|
| 1946 | 1948 | >> 8); |
|---|
| 1947 | | - ret |= SC301IOT_write_reg(SC301IOT->client, |
|---|
| 1949 | + ret |= sc301iot_write_reg(sc301iot->client, |
|---|
| 1948 | 1950 | SC301IOT_REG_VTS_L, |
|---|
| 1949 | 1951 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1950 | | - (ctrl->val + SC301IOT->cur_mode->height) |
|---|
| 1952 | + (ctrl->val + sc301iot->cur_mode->height) |
|---|
| 1951 | 1953 | & 0xff); |
|---|
| 1952 | 1954 | if (!ret) |
|---|
| 1953 | | - SC301IOT->cur_vts = ctrl->val + SC301IOT->cur_mode->height; |
|---|
| 1954 | | - if (SC301IOT->cur_vts != SC301IOT->cur_mode->vts_def) |
|---|
| 1955 | | - SC301IOT_modify_fps_info(SC301IOT); |
|---|
| 1955 | + sc301iot->cur_vts = ctrl->val + sc301iot->cur_mode->height; |
|---|
| 1956 | + sc301iot_modify_fps_info(sc301iot); |
|---|
| 1956 | 1957 | break; |
|---|
| 1957 | 1958 | case V4L2_CID_TEST_PATTERN: |
|---|
| 1958 | | - ret = SC301IOT_enable_test_pattern(SC301IOT, ctrl->val); |
|---|
| 1959 | + ret = sc301iot_enable_test_pattern(sc301iot, ctrl->val); |
|---|
| 1959 | 1960 | break; |
|---|
| 1960 | 1961 | case V4L2_CID_HFLIP: |
|---|
| 1961 | | - ret = SC301IOT_read_reg(SC301IOT->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1962 | + ret = sc301iot_read_reg(sc301iot->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1962 | 1963 | SC301IOT_REG_VALUE_08BIT, &val); |
|---|
| 1963 | | - ret |= SC301IOT_write_reg(SC301IOT->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1964 | + ret |= sc301iot_write_reg(sc301iot->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1964 | 1965 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1965 | 1966 | SC301IOT_FETCH_MIRROR(val, ctrl->val)); |
|---|
| 1966 | 1967 | break; |
|---|
| 1967 | 1968 | case V4L2_CID_VFLIP: |
|---|
| 1968 | | - ret = SC301IOT_read_reg(SC301IOT->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1969 | + ret = sc301iot_read_reg(sc301iot->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1969 | 1970 | SC301IOT_REG_VALUE_08BIT, &val); |
|---|
| 1970 | | - ret |= SC301IOT_write_reg(SC301IOT->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1971 | + ret |= sc301iot_write_reg(sc301iot->client, SC301IOT_FLIP_MIRROR_REG, |
|---|
| 1971 | 1972 | SC301IOT_REG_VALUE_08BIT, |
|---|
| 1972 | 1973 | SC301IOT_FETCH_FLIP(val, ctrl->val)); |
|---|
| 1973 | 1974 | break; |
|---|
| .. | .. |
|---|
| 1982 | 1983 | return ret; |
|---|
| 1983 | 1984 | } |
|---|
| 1984 | 1985 | |
|---|
| 1985 | | -static const struct v4l2_ctrl_ops SC301IOT_ctrl_ops = { |
|---|
| 1986 | | - .s_ctrl = SC301IOT_set_ctrl, |
|---|
| 1986 | +static const struct v4l2_ctrl_ops sc301iot_ctrl_ops = { |
|---|
| 1987 | + .s_ctrl = sc301iot_set_ctrl, |
|---|
| 1987 | 1988 | }; |
|---|
| 1988 | 1989 | |
|---|
| 1989 | | -static int SC301IOT_initialize_controls(struct SC301IOT *SC301IOT) |
|---|
| 1990 | +static int sc301iot_initialize_controls(struct sc301iot *sc301iot) |
|---|
| 1990 | 1991 | { |
|---|
| 1991 | | - const struct SC301IOT_mode *mode; |
|---|
| 1992 | + const struct sc301iot_mode *mode; |
|---|
| 1992 | 1993 | struct v4l2_ctrl_handler *handler; |
|---|
| 1993 | 1994 | struct v4l2_ctrl *ctrl; |
|---|
| 1994 | 1995 | s64 exposure_max, vblank_def; |
|---|
| 1995 | 1996 | u32 h_blank; |
|---|
| 1996 | 1997 | int ret; |
|---|
| 1997 | 1998 | |
|---|
| 1998 | | - handler = &SC301IOT->ctrl_handler; |
|---|
| 1999 | | - mode = SC301IOT->cur_mode; |
|---|
| 1999 | + handler = &sc301iot->ctrl_handler; |
|---|
| 2000 | + mode = sc301iot->cur_mode; |
|---|
| 2000 | 2001 | ret = v4l2_ctrl_handler_init(handler, 9); |
|---|
| 2001 | 2002 | if (ret) |
|---|
| 2002 | 2003 | return ret; |
|---|
| 2003 | | - handler->lock = &SC301IOT->mutex; |
|---|
| 2004 | + handler->lock = &sc301iot->mutex; |
|---|
| 2004 | 2005 | |
|---|
| 2005 | 2006 | ctrl = v4l2_ctrl_new_int_menu(handler, NULL, V4L2_CID_LINK_FREQ, |
|---|
| 2006 | 2007 | 0, 0, link_freq_menu_items); |
|---|
| .. | .. |
|---|
| 2011 | 2012 | 0, PIXEL_RATE_WITH_594M_10BIT, 1, PIXEL_RATE_WITH_594M_10BIT); |
|---|
| 2012 | 2013 | |
|---|
| 2013 | 2014 | h_blank = mode->hts_def - mode->width; |
|---|
| 2014 | | - SC301IOT->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, |
|---|
| 2015 | + sc301iot->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, |
|---|
| 2015 | 2016 | h_blank, h_blank, 1, h_blank); |
|---|
| 2016 | | - if (SC301IOT->hblank) |
|---|
| 2017 | | - SC301IOT->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; |
|---|
| 2017 | + if (sc301iot->hblank) |
|---|
| 2018 | + sc301iot->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; |
|---|
| 2018 | 2019 | vblank_def = mode->vts_def - mode->height; |
|---|
| 2019 | | - SC301IOT->vblank = v4l2_ctrl_new_std(handler, &SC301IOT_ctrl_ops, |
|---|
| 2020 | + sc301iot->vblank = v4l2_ctrl_new_std(handler, &sc301iot_ctrl_ops, |
|---|
| 2020 | 2021 | V4L2_CID_VBLANK, vblank_def, |
|---|
| 2021 | 2022 | SC301IOT_VTS_MAX - mode->height, |
|---|
| 2022 | 2023 | 1, vblank_def); |
|---|
| 2023 | 2024 | exposure_max = mode->vts_def - 8; |
|---|
| 2024 | | - SC301IOT->exposure = v4l2_ctrl_new_std(handler, &SC301IOT_ctrl_ops, |
|---|
| 2025 | + sc301iot->exposure = v4l2_ctrl_new_std(handler, &sc301iot_ctrl_ops, |
|---|
| 2025 | 2026 | V4L2_CID_EXPOSURE, SC301IOT_EXPOSURE_MIN, |
|---|
| 2026 | 2027 | exposure_max, SC301IOT_EXPOSURE_STEP, |
|---|
| 2027 | 2028 | mode->exp_def); |
|---|
| 2028 | | - SC301IOT->anal_gain = v4l2_ctrl_new_std(handler, &SC301IOT_ctrl_ops, |
|---|
| 2029 | + sc301iot->anal_gain = v4l2_ctrl_new_std(handler, &sc301iot_ctrl_ops, |
|---|
| 2029 | 2030 | V4L2_CID_ANALOGUE_GAIN, SC301IOT_GAIN_MIN, |
|---|
| 2030 | 2031 | SC301IOT_GAIN_MAX, SC301IOT_GAIN_STEP, |
|---|
| 2031 | 2032 | SC301IOT_GAIN_DEFAULT); |
|---|
| 2032 | | - SC301IOT->test_pattern = v4l2_ctrl_new_std_menu_items(handler, |
|---|
| 2033 | | - &SC301IOT_ctrl_ops, |
|---|
| 2033 | + sc301iot->test_pattern = v4l2_ctrl_new_std_menu_items(handler, |
|---|
| 2034 | + &sc301iot_ctrl_ops, |
|---|
| 2034 | 2035 | V4L2_CID_TEST_PATTERN, |
|---|
| 2035 | | - ARRAY_SIZE(SC301IOT_test_pattern_menu) - 1, |
|---|
| 2036 | | - 0, 0, SC301IOT_test_pattern_menu); |
|---|
| 2037 | | - v4l2_ctrl_new_std(handler, &SC301IOT_ctrl_ops, |
|---|
| 2036 | + ARRAY_SIZE(sc301iot_test_pattern_menu) - 1, |
|---|
| 2037 | + 0, 0, sc301iot_test_pattern_menu); |
|---|
| 2038 | + v4l2_ctrl_new_std(handler, &sc301iot_ctrl_ops, |
|---|
| 2038 | 2039 | V4L2_CID_HFLIP, 0, 1, 1, 0); |
|---|
| 2039 | 2040 | |
|---|
| 2040 | | - v4l2_ctrl_new_std(handler, &SC301IOT_ctrl_ops, |
|---|
| 2041 | + v4l2_ctrl_new_std(handler, &sc301iot_ctrl_ops, |
|---|
| 2041 | 2042 | V4L2_CID_VFLIP, 0, 1, 1, 0); |
|---|
| 2042 | 2043 | |
|---|
| 2043 | 2044 | if (handler->error) { |
|---|
| 2044 | 2045 | ret = handler->error; |
|---|
| 2045 | | - dev_err(&SC301IOT->client->dev, |
|---|
| 2046 | + dev_err(&sc301iot->client->dev, |
|---|
| 2046 | 2047 | "Failed to init controls(%d)\n", ret); |
|---|
| 2047 | 2048 | goto err_free_handler; |
|---|
| 2048 | 2049 | } |
|---|
| 2049 | 2050 | |
|---|
| 2050 | | - SC301IOT->subdev.ctrl_handler = handler; |
|---|
| 2051 | | - SC301IOT->has_init_exp = false; |
|---|
| 2052 | | - SC301IOT->cur_fps = mode->max_fps; |
|---|
| 2053 | | - SC301IOT->cur_vts = mode->vts_def; |
|---|
| 2051 | + sc301iot->subdev.ctrl_handler = handler; |
|---|
| 2052 | + sc301iot->has_init_exp = false; |
|---|
| 2053 | + sc301iot->cur_fps = mode->max_fps; |
|---|
| 2054 | + sc301iot->cur_vts = mode->vts_def; |
|---|
| 2054 | 2055 | |
|---|
| 2055 | 2056 | return 0; |
|---|
| 2056 | 2057 | |
|---|
| .. | .. |
|---|
| 2060 | 2061 | return ret; |
|---|
| 2061 | 2062 | } |
|---|
| 2062 | 2063 | |
|---|
| 2063 | | -static int SC301IOT_check_sensor_id(struct SC301IOT *SC301IOT, |
|---|
| 2064 | +static int sc301iot_check_sensor_id(struct sc301iot *sc301iot, |
|---|
| 2064 | 2065 | struct i2c_client *client) |
|---|
| 2065 | 2066 | { |
|---|
| 2066 | | - struct device *dev = &SC301IOT->client->dev; |
|---|
| 2067 | + struct device *dev = &sc301iot->client->dev; |
|---|
| 2067 | 2068 | u32 id = 0; |
|---|
| 2068 | 2069 | int ret; |
|---|
| 2069 | 2070 | |
|---|
| 2070 | | - if (SC301IOT->is_thunderboot) { |
|---|
| 2071 | + if (sc301iot->is_thunderboot) { |
|---|
| 2071 | 2072 | dev_info(dev, "Enable thunderboot mode, skip sensor id check\n"); |
|---|
| 2072 | 2073 | return 0; |
|---|
| 2073 | 2074 | } |
|---|
| 2074 | 2075 | |
|---|
| 2075 | | - ret = SC301IOT_read_reg(client, SC301IOT_REG_CHIP_ID, |
|---|
| 2076 | + ret = sc301iot_read_reg(client, SC301IOT_REG_CHIP_ID, |
|---|
| 2076 | 2077 | SC301IOT_REG_VALUE_16BIT, &id); |
|---|
| 2077 | 2078 | if (id != CHIP_ID) { |
|---|
| 2078 | 2079 | dev_err(dev, "Unexpected chip id(0x%04x), ret(%d)\n", id, ret); |
|---|
| .. | .. |
|---|
| 2084 | 2085 | return 0; |
|---|
| 2085 | 2086 | } |
|---|
| 2086 | 2087 | |
|---|
| 2087 | | -static int SC301IOT_configure_regulators(struct SC301IOT *SC301IOT) |
|---|
| 2088 | +static int sc301iot_configure_regulators(struct sc301iot *sc301iot) |
|---|
| 2088 | 2089 | { |
|---|
| 2089 | 2090 | unsigned int i; |
|---|
| 2090 | 2091 | |
|---|
| 2091 | 2092 | for (i = 0; i < SC301IOT_NUM_SUPPLIES; i++) |
|---|
| 2092 | | - SC301IOT->supplies[i].supply = SC301IOT_supply_names[i]; |
|---|
| 2093 | + sc301iot->supplies[i].supply = SC301IOT_supply_names[i]; |
|---|
| 2093 | 2094 | |
|---|
| 2094 | | - return devm_regulator_bulk_get(&SC301IOT->client->dev, |
|---|
| 2095 | + return devm_regulator_bulk_get(&sc301iot->client->dev, |
|---|
| 2095 | 2096 | SC301IOT_NUM_SUPPLIES, |
|---|
| 2096 | | - SC301IOT->supplies); |
|---|
| 2097 | + sc301iot->supplies); |
|---|
| 2097 | 2098 | } |
|---|
| 2098 | 2099 | |
|---|
| 2099 | | -static int SC301IOT_probe(struct i2c_client *client, |
|---|
| 2100 | +static int sc301iot_probe(struct i2c_client *client, |
|---|
| 2100 | 2101 | const struct i2c_device_id *id) |
|---|
| 2101 | 2102 | { |
|---|
| 2102 | 2103 | struct device *dev = &client->dev; |
|---|
| 2103 | 2104 | struct device_node *node = dev->of_node; |
|---|
| 2104 | | - struct SC301IOT *SC301IOT; |
|---|
| 2105 | + struct sc301iot *sc301iot; |
|---|
| 2105 | 2106 | struct v4l2_subdev *sd; |
|---|
| 2106 | 2107 | char facing[2]; |
|---|
| 2107 | 2108 | int ret; |
|---|
| .. | .. |
|---|
| 2113 | 2114 | (DRIVER_VERSION & 0xff00) >> 8, |
|---|
| 2114 | 2115 | DRIVER_VERSION & 0x00ff); |
|---|
| 2115 | 2116 | |
|---|
| 2116 | | - SC301IOT = devm_kzalloc(dev, sizeof(*SC301IOT), GFP_KERNEL); |
|---|
| 2117 | | - if (!SC301IOT) |
|---|
| 2117 | + sc301iot = devm_kzalloc(dev, sizeof(*sc301iot), GFP_KERNEL); |
|---|
| 2118 | + if (!sc301iot) |
|---|
| 2118 | 2119 | return -ENOMEM; |
|---|
| 2119 | 2120 | |
|---|
| 2120 | 2121 | of_property_read_u32(node, OF_CAMERA_HDR_MODE, &hdr_mode); |
|---|
| 2121 | 2122 | ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX, |
|---|
| 2122 | | - &SC301IOT->module_index); |
|---|
| 2123 | + &sc301iot->module_index); |
|---|
| 2123 | 2124 | ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING, |
|---|
| 2124 | | - &SC301IOT->module_facing); |
|---|
| 2125 | + &sc301iot->module_facing); |
|---|
| 2125 | 2126 | ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_NAME, |
|---|
| 2126 | | - &SC301IOT->module_name); |
|---|
| 2127 | + &sc301iot->module_name); |
|---|
| 2127 | 2128 | ret |= of_property_read_string(node, RKMODULE_CAMERA_LENS_NAME, |
|---|
| 2128 | | - &SC301IOT->len_name); |
|---|
| 2129 | + &sc301iot->len_name); |
|---|
| 2129 | 2130 | if (ret) { |
|---|
| 2130 | 2131 | dev_err(dev, "could not get module information!\n"); |
|---|
| 2131 | 2132 | return -EINVAL; |
|---|
| 2132 | 2133 | } |
|---|
| 2133 | 2134 | |
|---|
| 2134 | | - SC301IOT->is_thunderboot = IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP); |
|---|
| 2135 | | - SC301IOT->sync_mode = NO_SYNC_MODE; |
|---|
| 2135 | + sc301iot->is_thunderboot = IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP); |
|---|
| 2136 | + sc301iot->sync_mode = NO_SYNC_MODE; |
|---|
| 2136 | 2137 | ret = of_property_read_string(node, RKMODULE_CAMERA_SYNC_MODE, &sync_mode_name); |
|---|
| 2137 | 2138 | if (!ret) { |
|---|
| 2138 | 2139 | if (strcmp(sync_mode_name, RKMODULE_EXTERNAL_MASTER_MODE) == 0) |
|---|
| 2139 | | - SC301IOT->sync_mode = EXTERNAL_MASTER_MODE; |
|---|
| 2140 | + sc301iot->sync_mode = EXTERNAL_MASTER_MODE; |
|---|
| 2140 | 2141 | else if (strcmp(sync_mode_name, RKMODULE_INTERNAL_MASTER_MODE) == 0) |
|---|
| 2141 | | - SC301IOT->sync_mode = INTERNAL_MASTER_MODE; |
|---|
| 2142 | + sc301iot->sync_mode = INTERNAL_MASTER_MODE; |
|---|
| 2142 | 2143 | else if (strcmp(sync_mode_name, RKMODULE_SLAVE_MODE) == 0) |
|---|
| 2143 | | - SC301IOT->sync_mode = SLAVE_MODE; |
|---|
| 2144 | + sc301iot->sync_mode = SLAVE_MODE; |
|---|
| 2144 | 2145 | } |
|---|
| 2145 | 2146 | |
|---|
| 2146 | | - switch (SC301IOT->sync_mode) { |
|---|
| 2147 | + switch (sc301iot->sync_mode) { |
|---|
| 2147 | 2148 | default: |
|---|
| 2148 | | - SC301IOT->sync_mode = NO_SYNC_MODE; break; |
|---|
| 2149 | + sc301iot->sync_mode = NO_SYNC_MODE; break; |
|---|
| 2149 | 2150 | case NO_SYNC_MODE: |
|---|
| 2150 | 2151 | dev_info(dev, "sync_mode = [NO_SYNC_MODE]\n"); break; |
|---|
| 2151 | 2152 | case EXTERNAL_MASTER_MODE: |
|---|
| .. | .. |
|---|
| 2155 | 2156 | dev_info(dev, "sync_mode = [SLAVE_MODE]\n"); break; |
|---|
| 2156 | 2157 | } |
|---|
| 2157 | 2158 | |
|---|
| 2158 | | - SC301IOT->client = client; |
|---|
| 2159 | + sc301iot->client = client; |
|---|
| 2159 | 2160 | for (i = 0; i < ARRAY_SIZE(supported_modes); i++) { |
|---|
| 2160 | 2161 | if (hdr_mode == supported_modes[i].hdr_mode) { |
|---|
| 2161 | | - SC301IOT->cur_mode = &supported_modes[i]; |
|---|
| 2162 | + sc301iot->cur_mode = &supported_modes[i]; |
|---|
| 2162 | 2163 | break; |
|---|
| 2163 | 2164 | } |
|---|
| 2164 | 2165 | } |
|---|
| 2165 | 2166 | if (i == ARRAY_SIZE(supported_modes)) |
|---|
| 2166 | | - SC301IOT->cur_mode = &supported_modes[0]; |
|---|
| 2167 | + sc301iot->cur_mode = &supported_modes[0]; |
|---|
| 2167 | 2168 | |
|---|
| 2168 | | - SC301IOT->xvclk = devm_clk_get(dev, "xvclk"); |
|---|
| 2169 | | - if (IS_ERR(SC301IOT->xvclk)) { |
|---|
| 2169 | + sc301iot->xvclk = devm_clk_get(dev, "xvclk"); |
|---|
| 2170 | + if (IS_ERR(sc301iot->xvclk)) { |
|---|
| 2170 | 2171 | dev_err(dev, "Failed to get xvclk\n"); |
|---|
| 2171 | 2172 | return -EINVAL; |
|---|
| 2172 | 2173 | } |
|---|
| 2173 | 2174 | |
|---|
| 2174 | | - if (SC301IOT->is_thunderboot) { |
|---|
| 2175 | | - SC301IOT->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS); |
|---|
| 2176 | | - if (IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 2175 | + if (sc301iot->is_thunderboot) { |
|---|
| 2176 | + sc301iot->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS); |
|---|
| 2177 | + if (IS_ERR(sc301iot->reset_gpio)) |
|---|
| 2177 | 2178 | dev_warn(dev, "Failed to get reset-gpios\n"); |
|---|
| 2178 | 2179 | |
|---|
| 2179 | | - SC301IOT->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS); |
|---|
| 2180 | | - if (IS_ERR(SC301IOT->pwdn_gpio)) |
|---|
| 2180 | + sc301iot->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS); |
|---|
| 2181 | + if (IS_ERR(sc301iot->pwdn_gpio)) |
|---|
| 2181 | 2182 | dev_warn(dev, "Failed to get pwdn-gpios\n"); |
|---|
| 2182 | 2183 | } else { |
|---|
| 2183 | | - SC301IOT->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); |
|---|
| 2184 | | - if (IS_ERR(SC301IOT->reset_gpio)) |
|---|
| 2184 | + sc301iot->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); |
|---|
| 2185 | + if (IS_ERR(sc301iot->reset_gpio)) |
|---|
| 2185 | 2186 | dev_warn(dev, "Failed to get reset-gpios\n"); |
|---|
| 2186 | 2187 | |
|---|
| 2187 | | - SC301IOT->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); |
|---|
| 2188 | | - if (IS_ERR(SC301IOT->pwdn_gpio)) |
|---|
| 2188 | + sc301iot->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); |
|---|
| 2189 | + if (IS_ERR(sc301iot->pwdn_gpio)) |
|---|
| 2189 | 2190 | dev_warn(dev, "Failed to get pwdn-gpios\n"); |
|---|
| 2190 | 2191 | } |
|---|
| 2191 | 2192 | |
|---|
| 2192 | | - SC301IOT->pinctrl = devm_pinctrl_get(dev); |
|---|
| 2193 | | - if (!IS_ERR(SC301IOT->pinctrl)) { |
|---|
| 2194 | | - SC301IOT->pins_default = |
|---|
| 2195 | | - pinctrl_lookup_state(SC301IOT->pinctrl, |
|---|
| 2193 | + sc301iot->pinctrl = devm_pinctrl_get(dev); |
|---|
| 2194 | + if (!IS_ERR(sc301iot->pinctrl)) { |
|---|
| 2195 | + sc301iot->pins_default = |
|---|
| 2196 | + pinctrl_lookup_state(sc301iot->pinctrl, |
|---|
| 2196 | 2197 | OF_CAMERA_PINCTRL_STATE_DEFAULT); |
|---|
| 2197 | | - if (IS_ERR(SC301IOT->pins_default)) |
|---|
| 2198 | + if (IS_ERR(sc301iot->pins_default)) |
|---|
| 2198 | 2199 | dev_err(dev, "could not get default pinstate\n"); |
|---|
| 2199 | 2200 | |
|---|
| 2200 | | - SC301IOT->pins_sleep = |
|---|
| 2201 | | - pinctrl_lookup_state(SC301IOT->pinctrl, |
|---|
| 2201 | + sc301iot->pins_sleep = |
|---|
| 2202 | + pinctrl_lookup_state(sc301iot->pinctrl, |
|---|
| 2202 | 2203 | OF_CAMERA_PINCTRL_STATE_SLEEP); |
|---|
| 2203 | | - if (IS_ERR(SC301IOT->pins_sleep)) |
|---|
| 2204 | + if (IS_ERR(sc301iot->pins_sleep)) |
|---|
| 2204 | 2205 | dev_err(dev, "could not get sleep pinstate\n"); |
|---|
| 2205 | 2206 | } else { |
|---|
| 2206 | 2207 | dev_err(dev, "no pinctrl\n"); |
|---|
| 2207 | 2208 | } |
|---|
| 2208 | 2209 | |
|---|
| 2209 | | - ret = SC301IOT_configure_regulators(SC301IOT); |
|---|
| 2210 | + ret = sc301iot_configure_regulators(sc301iot); |
|---|
| 2210 | 2211 | if (ret) { |
|---|
| 2211 | 2212 | dev_err(dev, "Failed to get power regulators\n"); |
|---|
| 2212 | 2213 | return ret; |
|---|
| 2213 | 2214 | } |
|---|
| 2214 | 2215 | |
|---|
| 2215 | | - mutex_init(&SC301IOT->mutex); |
|---|
| 2216 | + mutex_init(&sc301iot->mutex); |
|---|
| 2216 | 2217 | |
|---|
| 2217 | | - sd = &SC301IOT->subdev; |
|---|
| 2218 | | - v4l2_i2c_subdev_init(sd, client, &SC301IOT_subdev_ops); |
|---|
| 2219 | | - ret = SC301IOT_initialize_controls(SC301IOT); |
|---|
| 2218 | + sd = &sc301iot->subdev; |
|---|
| 2219 | + v4l2_i2c_subdev_init(sd, client, &sc301iot_subdev_ops); |
|---|
| 2220 | + ret = sc301iot_initialize_controls(sc301iot); |
|---|
| 2220 | 2221 | if (ret) |
|---|
| 2221 | 2222 | goto err_destroy_mutex; |
|---|
| 2222 | 2223 | |
|---|
| 2223 | | - ret = __SC301IOT_power_on(SC301IOT); |
|---|
| 2224 | + ret = __sc301iot_power_on(sc301iot); |
|---|
| 2224 | 2225 | if (ret) |
|---|
| 2225 | 2226 | goto err_free_handler; |
|---|
| 2226 | 2227 | |
|---|
| 2227 | | - ret = SC301IOT_check_sensor_id(SC301IOT, client); |
|---|
| 2228 | + ret = sc301iot_check_sensor_id(sc301iot, client); |
|---|
| 2228 | 2229 | if (ret) |
|---|
| 2229 | 2230 | goto err_power_off; |
|---|
| 2230 | 2231 | |
|---|
| 2231 | 2232 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
|---|
| 2232 | | - sd->internal_ops = &SC301IOT_internal_ops; |
|---|
| 2233 | + sd->internal_ops = &sc301iot_internal_ops; |
|---|
| 2233 | 2234 | sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | |
|---|
| 2234 | 2235 | V4L2_SUBDEV_FL_HAS_EVENTS; |
|---|
| 2235 | 2236 | #endif |
|---|
| 2236 | 2237 | #if defined(CONFIG_MEDIA_CONTROLLER) |
|---|
| 2237 | | - SC301IOT->pad.flags = MEDIA_PAD_FL_SOURCE; |
|---|
| 2238 | + sc301iot->pad.flags = MEDIA_PAD_FL_SOURCE; |
|---|
| 2238 | 2239 | sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; |
|---|
| 2239 | | - ret = media_entity_pads_init(&sd->entity, 1, &SC301IOT->pad); |
|---|
| 2240 | + ret = media_entity_pads_init(&sd->entity, 1, &sc301iot->pad); |
|---|
| 2240 | 2241 | if (ret < 0) |
|---|
| 2241 | 2242 | goto err_power_off; |
|---|
| 2242 | 2243 | #endif |
|---|
| 2243 | 2244 | |
|---|
| 2244 | 2245 | memset(facing, 0, sizeof(facing)); |
|---|
| 2245 | | - if (strcmp(SC301IOT->module_facing, "back") == 0) |
|---|
| 2246 | + if (strcmp(sc301iot->module_facing, "back") == 0) |
|---|
| 2246 | 2247 | facing[0] = 'b'; |
|---|
| 2247 | 2248 | else |
|---|
| 2248 | 2249 | facing[0] = 'f'; |
|---|
| 2249 | 2250 | |
|---|
| 2250 | 2251 | snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", |
|---|
| 2251 | | - SC301IOT->module_index, facing, |
|---|
| 2252 | + sc301iot->module_index, facing, |
|---|
| 2252 | 2253 | SC301IOT_NAME, dev_name(sd->dev)); |
|---|
| 2253 | 2254 | ret = v4l2_async_register_subdev_sensor_common(sd); |
|---|
| 2254 | 2255 | if (ret) { |
|---|
| .. | .. |
|---|
| 2258 | 2259 | |
|---|
| 2259 | 2260 | pm_runtime_set_active(dev); |
|---|
| 2260 | 2261 | pm_runtime_enable(dev); |
|---|
| 2261 | | - pm_runtime_idle(dev); |
|---|
| 2262 | + if (sc301iot->is_thunderboot) |
|---|
| 2263 | + pm_runtime_get_sync(dev); |
|---|
| 2264 | + else |
|---|
| 2265 | + pm_runtime_idle(dev); |
|---|
| 2262 | 2266 | |
|---|
| 2263 | 2267 | return 0; |
|---|
| 2264 | 2268 | |
|---|
| .. | .. |
|---|
| 2267 | 2271 | media_entity_cleanup(&sd->entity); |
|---|
| 2268 | 2272 | #endif |
|---|
| 2269 | 2273 | err_power_off: |
|---|
| 2270 | | - __SC301IOT_power_off(SC301IOT); |
|---|
| 2274 | + __sc301iot_power_off(sc301iot); |
|---|
| 2271 | 2275 | err_free_handler: |
|---|
| 2272 | | - v4l2_ctrl_handler_free(&SC301IOT->ctrl_handler); |
|---|
| 2276 | + v4l2_ctrl_handler_free(&sc301iot->ctrl_handler); |
|---|
| 2273 | 2277 | err_destroy_mutex: |
|---|
| 2274 | | - mutex_destroy(&SC301IOT->mutex); |
|---|
| 2278 | + mutex_destroy(&sc301iot->mutex); |
|---|
| 2275 | 2279 | |
|---|
| 2276 | 2280 | return ret; |
|---|
| 2277 | 2281 | } |
|---|
| 2278 | 2282 | |
|---|
| 2279 | | -static int SC301IOT_remove(struct i2c_client *client) |
|---|
| 2283 | +static int sc301iot_remove(struct i2c_client *client) |
|---|
| 2280 | 2284 | { |
|---|
| 2281 | 2285 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
|---|
| 2282 | | - struct SC301IOT *SC301IOT = to_SC301IOT(sd); |
|---|
| 2286 | + struct sc301iot *sc301iot = to_sc301iot(sd); |
|---|
| 2283 | 2287 | |
|---|
| 2284 | 2288 | v4l2_async_unregister_subdev(sd); |
|---|
| 2285 | 2289 | #if defined(CONFIG_MEDIA_CONTROLLER) |
|---|
| 2286 | 2290 | media_entity_cleanup(&sd->entity); |
|---|
| 2287 | 2291 | #endif |
|---|
| 2288 | | - v4l2_ctrl_handler_free(&SC301IOT->ctrl_handler); |
|---|
| 2289 | | - mutex_destroy(&SC301IOT->mutex); |
|---|
| 2292 | + v4l2_ctrl_handler_free(&sc301iot->ctrl_handler); |
|---|
| 2293 | + mutex_destroy(&sc301iot->mutex); |
|---|
| 2290 | 2294 | |
|---|
| 2291 | 2295 | pm_runtime_disable(&client->dev); |
|---|
| 2292 | 2296 | if (!pm_runtime_status_suspended(&client->dev)) |
|---|
| 2293 | | - __SC301IOT_power_off(SC301IOT); |
|---|
| 2297 | + __sc301iot_power_off(sc301iot); |
|---|
| 2294 | 2298 | pm_runtime_set_suspended(&client->dev); |
|---|
| 2295 | 2299 | |
|---|
| 2296 | 2300 | return 0; |
|---|
| 2297 | 2301 | } |
|---|
| 2298 | 2302 | |
|---|
| 2299 | 2303 | #if IS_ENABLED(CONFIG_OF) |
|---|
| 2300 | | -static const struct of_device_id SC301IOT_of_match[] = { |
|---|
| 2301 | | - { .compatible = "smartsens,SC301IOT" }, |
|---|
| 2304 | +static const struct of_device_id sc301iot_of_match[] = { |
|---|
| 2305 | + { .compatible = "smartsens,sc301iot" }, |
|---|
| 2302 | 2306 | {}, |
|---|
| 2303 | 2307 | }; |
|---|
| 2304 | | -MODULE_DEVICE_TABLE(of, SC301IOT_of_match); |
|---|
| 2308 | +MODULE_DEVICE_TABLE(of, sc301iot_of_match); |
|---|
| 2305 | 2309 | #endif |
|---|
| 2306 | 2310 | |
|---|
| 2307 | | -static const struct i2c_device_id SC301IOT_match_id[] = { |
|---|
| 2308 | | - { "smartsens,SC301IOT", 0 }, |
|---|
| 2311 | +static const struct i2c_device_id sc301iot_match_id[] = { |
|---|
| 2312 | + { "smartsens,sc301iot", 0 }, |
|---|
| 2309 | 2313 | { }, |
|---|
| 2310 | 2314 | }; |
|---|
| 2311 | 2315 | |
|---|
| 2312 | | -static struct i2c_driver SC301IOT_i2c_driver = { |
|---|
| 2316 | +static struct i2c_driver sc301iot_i2c_driver = { |
|---|
| 2313 | 2317 | .driver = { |
|---|
| 2314 | 2318 | .name = SC301IOT_NAME, |
|---|
| 2315 | | - .pm = &SC301IOT_pm_ops, |
|---|
| 2316 | | - .of_match_table = of_match_ptr(SC301IOT_of_match), |
|---|
| 2319 | + .pm = &sc301iot_pm_ops, |
|---|
| 2320 | + .of_match_table = of_match_ptr(sc301iot_of_match), |
|---|
| 2317 | 2321 | }, |
|---|
| 2318 | | - .probe = &SC301IOT_probe, |
|---|
| 2319 | | - .remove = &SC301IOT_remove, |
|---|
| 2320 | | - .id_table = SC301IOT_match_id, |
|---|
| 2322 | + .probe = &sc301iot_probe, |
|---|
| 2323 | + .remove = &sc301iot_remove, |
|---|
| 2324 | + .id_table = sc301iot_match_id, |
|---|
| 2321 | 2325 | }; |
|---|
| 2322 | 2326 | |
|---|
| 2323 | 2327 | static int __init sensor_mod_init(void) |
|---|
| 2324 | 2328 | { |
|---|
| 2325 | | - return i2c_add_driver(&SC301IOT_i2c_driver); |
|---|
| 2329 | + return i2c_add_driver(&sc301iot_i2c_driver); |
|---|
| 2326 | 2330 | } |
|---|
| 2327 | 2331 | |
|---|
| 2328 | 2332 | static void __exit sensor_mod_exit(void) |
|---|
| 2329 | 2333 | { |
|---|
| 2330 | | - i2c_del_driver(&SC301IOT_i2c_driver); |
|---|
| 2334 | + i2c_del_driver(&sc301iot_i2c_driver); |
|---|
| 2331 | 2335 | } |
|---|
| 2332 | 2336 | |
|---|
| 2333 | 2337 | #if defined(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP) && !defined(CONFIG_INITCALL_ASYNC) |
|---|
| .. | .. |
|---|
| 2337 | 2341 | #endif |
|---|
| 2338 | 2342 | module_exit(sensor_mod_exit); |
|---|
| 2339 | 2343 | |
|---|
| 2340 | | -MODULE_DESCRIPTION("smartsens SC301IOT sensor driver"); |
|---|
| 2344 | +MODULE_DESCRIPTION("smartsens sc301iot sensor driver"); |
|---|
| 2341 | 2345 | MODULE_LICENSE("GPL"); |
|---|