hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/media/i2c/nvp6158_drv/nvp6158_v4l2.c
....@@ -8,9 +8,6 @@
88 * V0.0X01.0X01
99 * 1. add workqueue to detect ahd state.
1010 * 2. add more resolution support.
11
- * V0.0X01.0X02
12
- * 1. get init status before start workqueue.
13
- * 2. replace some dev_info to dev_dbg.
1411 */
1512
1613 #include <linux/clk.h>
....@@ -48,7 +45,7 @@
4845 #include "nvp6158_video_auto_detect.h"
4946 #include "nvp6158_drv.h"
5047
51
-#define WORK_QUEUE
48
+//#define WORK_QUEUE
5249
5350 #ifdef WORK_QUEUE
5451 #include <linux/workqueue.h>
....@@ -60,14 +57,14 @@
6057
6158 #endif
6259
63
-#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x2)
60
+#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x1)
6461
6562 #ifndef V4L2_CID_DIGITAL_GAIN
6663 #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN
6764 #endif
6865
6966 #define NVP6158_XVCLK_FREQ 24000000
70
-#define NVP6158_BITS_PER_SAMPLE 8
67
+#define NVP6158_BITS_PER_SAMPLE 8
7168
7269 /* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */
7370 #define NVP6158_PIXEL_RATE 297000000LL
....@@ -79,25 +76,17 @@
7976 #define OF_CAMERA_MODULE_REGULATOR_VOLTAGES "rockchip,regulator-voltages"
8077
8178 /* DVP MODE, BT1120 or BT656 */
82
-#define RK_CAMERA_MODULE_DVP_MODE "rockchip,dvp_mode"
79
+#define RK_CAMERA_MODULE_DVP_MODE "rockchip,dvp_mode"
8380 #define RK_CAMERA_MODULE_CHANNEL_NUMS "rockchip,channel_nums"
84
-#define RK_CAMERA_MODULE_DUAL_EDGE "rockchip,dual_edge"
81
+#define RK_CAMERA_MODULE_DUAL_EDGE "rockchip,dual_edge"
8582 #define RK_CAMERA_MODULE_DEFAULT_RECT "rockchip,default_rect"
8683
8784 #define NVP6158_DEFAULT_DVP_MODE "BT1120"
88
-#define NVP6158_DEFAULT_CHANNEL_NUMS 4U
85
+#define NVP6158_DEFAULT_CHANNEL_NUMS 4U
8986 #define NVP6158_DEFAULT_DUAL_EDGE 0U
9087 #define NVP6158_NAME "nvp6158"
91
-#define NVP6158_DEFAULT_WIDTH 1920
92
-#define NVP6158_DEFAULT_HEIGHT 1080
93
-
94
-enum nvp6158_max_pad {
95
- PAD0,
96
- PAD1,
97
- PAD2,
98
- PAD3,
99
- PAD_MAX,
100
-};
88
+#define NVP6158_DEFAULT_WIDTH 1920
89
+#define NVP6158_DEFAULT_HEIGHT 1080
10190
10291 struct nvp6158_gpio {
10392 int pltfrm_gpio;
....@@ -195,8 +184,7 @@
195184 .numerator = 10000,
196185 .denominator = 250000,
197186 },
198
- },
199
- {
187
+ }, {
200188 .width = 1920,
201189 .height = 1080,
202190 .fmt_idx = AHD20_1080P_25P,
....@@ -204,8 +192,7 @@
204192 .numerator = 10000,
205193 .denominator = 250000,
206194 },
207
- },
208
- {
195
+ }, {
209196 .width = 2048,
210197 .height = 1536,
211198 .fmt_idx = AHD30_3M_18P,
....@@ -213,8 +200,7 @@
213200 .numerator = 10000,
214201 .denominator = 180000,
215202 },
216
- },
217
- {
203
+ }, {
218204 .width = 1280,
219205 .height = 1440,
220206 .fmt_idx = AHD30_4M_30P,
....@@ -222,8 +208,7 @@
222208 .numerator = 10000,
223209 .denominator = 300000,
224210 },
225
- },
226
- {
211
+ }, {
227212 .width = 2560,
228213 .height = 1440,
229214 .fmt_idx = AHD30_4M_15P,
....@@ -231,8 +216,7 @@
231216 .numerator = 10000,
232217 .denominator = 150000,
233218 },
234
- },
235
- {
219
+ }, {
236220 .width = 2592,
237221 .height = 1944,
238222 .fmt_idx = AHD30_5M_12_5P,
....@@ -240,8 +224,7 @@
240224 .numerator = 10000,
241225 .denominator = 125000,
242226 },
243
- },
244
- {
227
+ }, {
245228 .width = 3840,
246229 .height = 2160,
247230 .fmt_idx = AHD30_8M_7_5P,
....@@ -249,10 +232,7 @@
249232 .numerator = 10000,
250233 .denominator = 75000,
251234 },
252
- },
253
-
254
- /* test modes, Interlace mode*/
255
- {
235
+ }, {/* test modes, Interlace mode*/
256236 .width = 720,
257237 .height = 480,
258238 .fmt_idx = AHD20_SD_SH720_NT,
....@@ -260,8 +240,7 @@
260240 .numerator = 10000,
261241 .denominator = 250000,
262242 },
263
- },
264
- {
243
+ }, {
265244 .width = 720,
266245 .height = 576,
267246 .fmt_idx = AHD20_SD_SH720_PAL,
....@@ -269,8 +248,7 @@
269248 .numerator = 10000,
270249 .denominator = 250000,
271250 },
272
- },
273
- {
251
+ }, {
274252 .width = 960,
275253 .height = 576,
276254 .fmt_idx = AHD20_SD_H960_PAL,
....@@ -278,8 +256,7 @@
278256 .numerator = 10000,
279257 .denominator = 250000,
280258 },
281
- },
282
- {
259
+ }, {
283260 .width = 1920,
284261 .height = 576,
285262 .fmt_idx = AHD20_SD_H960_EX_PAL,
....@@ -328,7 +305,7 @@
328305 u8 buf[2];
329306 int ret;
330307
331
- dev_dbg(&client->dev, "write reg(0x%x val:0x%x)!\n", reg, val);
308
+ dev_info(&client->dev, "write reg(0x%x val:0x%x)!\n", reg, val);
332309 buf[0] = reg & 0xFF;
333310 buf[1] = val;
334311
....@@ -624,7 +601,6 @@
624601 nvp6158->frame_size = match;
625602 }
626603
627
-static inline bool nvp6158_no_signal(struct v4l2_subdev *sd, u8 *novid);
628604 static int nvp6158_stream(struct v4l2_subdev *sd, int on)
629605 {
630606 struct i2c_client *client = v4l2_get_subdevdata(sd);
....@@ -652,12 +628,6 @@
652628 video_init.mode = nvp6158->mode;
653629 nvp6158_start(&video_init, nvp6158->dual_edge ? true : false);
654630 #ifdef WORK_QUEUE
655
- nvp6158->hot_plug = false;
656
- nvp6158->is_reset = 0;
657
- usleep_range(20000, 21000);
658
- /* get power on state first*/
659
- nvp6158_no_signal(sd, &nvp6158->last_detect_status);
660
-
661631 if (nvp6158->plug_state_check.state_check_wq) {
662632 dev_info(&client->dev, "%s queue_delayed_work 1000ms", __func__);
663633 queue_delayed_work(nvp6158->plug_state_check.state_check_wq,
....@@ -752,12 +722,12 @@
752722 dev_err(&client->dev, "Failed to read videoloss state!\n");
753723
754724 *novid = videoloss;
755
- dev_dbg(&client->dev, "%s: video loss status:0x%x.\n", __func__, videoloss);
725
+ dev_info(&client->dev, "%s: video loss status:0x%x.\n", __func__, videoloss);
756726 if (videoloss == 0xf) {
757
- dev_dbg(&client->dev, "%s: all channels No Video detected.\n", __func__);
727
+ dev_info(&client->dev, "%s: all channels No Video detected.\n", __func__);
758728 no_signal = true;
759729 } else {
760
- dev_dbg(&client->dev, "%s: channel has some video detection.\n", __func__);
730
+ dev_info(&client->dev, "%s: channel has some video detection.\n", __func__);
761731 no_signal = false;
762732 }
763733 return no_signal;
....@@ -776,14 +746,14 @@
776746 if (ret < 0)
777747 dev_err(&client->dev, "Failed to read sync state!\n");
778748
779
- dev_dbg(&client->dev, "%s: video AGC LOCK status:0x%x.\n",
749
+ dev_info(&client->dev, "%s: video AGC LOCK status:0x%x.\n",
780750 __func__, video_lock_status);
781751 *lock_st = video_lock_status;
782752 if (video_lock_status) {
783
- dev_dbg(&client->dev, "%s: channel has AGC LOCK.\n", __func__);
753
+ dev_info(&client->dev, "%s: channel has AGC LOCK.\n", __func__);
784754 has_sync = true;
785755 } else {
786
- dev_dbg(&client->dev, "%s: channel has no AGC LOCK.\n", __func__);
756
+ dev_info(&client->dev, "%s: channel has no AGC LOCK.\n", __func__);
787757 has_sync = false;
788758 }
789759 return has_sync;
....@@ -813,8 +783,10 @@
813783 nvp6158->hot_plug = false;
814784 nvp6158->last_detect_status = nvp6158->cur_detect_status;
815785
786
+ dev_info(&client->dev, "%s has plug motion? (%s)", __func__,
787
+ nvp6158->hot_plug ? "true" : "false");
816788 if (nvp6158->hot_plug) {
817
- dev_info(&client->dev, "queue_delayed_work 1500ms, has hot plug motion.");
789
+ dev_info(&client->dev, "queue_delayed_work 1500ms, if has hot plug motion.");
818790 queue_delayed_work(nvp6158->plug_state_check.state_check_wq,
819791 &nvp6158->plug_state_check.d_work, msecs_to_jiffies(1500));
820792 nvp6158_write(client, 0xFF, 0x20);
....@@ -822,14 +794,14 @@
822794 usleep_range(3000, 5000);
823795 nvp6158_write(client, 0x00, 0xFF);
824796 } else {
825
- dev_dbg(&client->dev, "queue_delayed_work 100ms, if no hot plug motion.");
797
+ dev_info(&client->dev, "queue_delayed_work 100ms, if no hot plug motion.");
826798 queue_delayed_work(nvp6158->plug_state_check.state_check_wq,
827799 &nvp6158->plug_state_check.d_work, msecs_to_jiffies(100));
828800 }
829801 }
830802 #endif
831803
832
-static int nvp6158_g_mbus_config(struct v4l2_subdev *sd,
804
+static int nvp6158_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
833805 struct v4l2_mbus_config *cfg)
834806 {
835807 struct nvp6158 *nvp6158 = to_nvp6158(sd);
....@@ -950,6 +922,17 @@
950922
951923 mutex_unlock(&nvp6158->mutex);
952924 return ret;
925
+}
926
+
927
+static int nvp6158_g_frame_interval(struct v4l2_subdev *sd,
928
+ struct v4l2_subdev_frame_interval *fi)
929
+{
930
+ struct nvp6158 *nvp6158 = to_nvp6158(sd);
931
+ const struct nvp6158_framesize *size = nvp6158->frame_size;
932
+
933
+ fi->interval = size->max_fps;
934
+
935
+ return 0;
953936 }
954937
955938 static void nvp6158_get_module_inf(struct nvp6158 *nvp6158,
....@@ -1201,8 +1184,8 @@
12011184
12021185 static const struct v4l2_subdev_video_ops nvp6158_video_ops = {
12031186 .s_stream = nvp6158_stream,
1204
- .g_mbus_config = nvp6158_g_mbus_config,
12051187 .querystd = nvp6158_querystd,
1188
+ .g_frame_interval = nvp6158_g_frame_interval,
12061189 };
12071190
12081191 static const struct v4l2_subdev_pad_ops nvp6158_subdev_pad_ops = {
....@@ -1212,6 +1195,7 @@
12121195 .set_fmt = nvp6158_set_fmt,
12131196 .get_selection = nvp6158_get_selection,
12141197 .enum_frame_interval = nvp6158_enum_frame_interval,
1198
+ .get_mbus_config = nvp6158_g_mbus_config,
12151199 };
12161200
12171201 static const struct v4l2_subdev_core_ops nvp6158_core_ops = {