forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 223293205a7265c8b02882461ba8996650048ade
kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c
....@@ -1,8 +1,8 @@
11 // SPDX-License-Identifier: GPL-2.0
22 /*
33 * jaguar1 driver
4
- *
5
- * V0.0X01.0X01 add workqueue to detect ahd state.
4
+ * V0.0X01.0X00 first version.
5
+ * V0.0X01.0X01 fix kernel5.10 compile error.
66 *
77 */
88
....@@ -39,18 +39,7 @@
3939 #include "jaguar1_video_eq.h"
4040 #include "jaguar1_mipi.h"
4141 #include "jaguar1_drv.h"
42
-
43
-#define WORK_QUEUE
44
-
45
-#ifdef WORK_QUEUE
46
-#include <linux/workqueue.h>
47
-
48
-struct sensor_state_check_work {
49
- struct workqueue_struct *state_check_wq;
50
- struct delayed_work d_work;
51
-};
52
-
53
-#endif
42
+#include "jaguar1_v4l2.h"
5443
5544 #define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x1)
5645
....@@ -81,14 +70,6 @@
8170
8271 /* #define FORCE_720P */
8372
84
-enum jaguar1_max_pad {
85
- PAD0,
86
- PAD1,
87
- PAD2,
88
- PAD3,
89
- PAD_MAX,
90
-};
91
-
9273 struct jaguar1_gpio {
9374 int pltfrm_gpio;
9475 const char *label;
....@@ -113,18 +94,14 @@
11394 struct jaguar1_framesize {
11495 u16 width;
11596 u16 height;
97
+ struct v4l2_fract max_fps;
11698 enum NC_VIVO_CH_FORMATDEF fmt_idx;
99
+ __u32 field;
117100 };
118101
119102 struct jaguar1_default_rect {
120103 unsigned int width;
121104 unsigned int height;
122
-};
123
-
124
-enum jaguar1_hot_plug_state {
125
- PLUG_IN = 0,
126
- PLUG_OUT,
127
- PLUG_STATE_MAX,
128105 };
129106
130107 struct jaguar1 {
....@@ -157,16 +134,6 @@
157134 const struct jaguar1_framesize *frame_size;
158135 int streaming;
159136 struct jaguar1_default_rect defrect;
160
-#ifdef WORK_QUEUE
161
- struct sensor_state_check_work plug_state_check;
162
- u8 cur_detect_status;
163
- u8 last_detect_status;
164
- u64 timestamp0;
165
- u64 timestamp1;
166
-#endif
167
- bool hot_plug;
168
- u8 is_reset;
169
- struct semaphore reg_sem;
170137 };
171138
172139 #define to_jaguar1(sd) container_of(sd, struct jaguar1, subdev)
....@@ -176,23 +143,62 @@
176143 {
177144 .width = 2560,
178145 .height = 1440,
146
+ .max_fps = {
147
+ .numerator = 10000,
148
+ .denominator = 250000,
149
+ },
179150 .fmt_idx = AHD20_720P_25P,
180151 }
181152 #else
182153 {
154
+ .width = 960,
155
+ .height = 480,
156
+ .max_fps = {
157
+ .numerator = 10000,
158
+ .denominator = 250000,
159
+ },
160
+ .fmt_idx = AHD20_SD_H960_2EX_Btype_NT,
161
+ .field = V4L2_FIELD_INTERLACED,
162
+ },
163
+ {
164
+ .width = 960,
165
+ .height = 576,
166
+ .max_fps = {
167
+ .numerator = 10000,
168
+ .denominator = 300000,
169
+ },
170
+ .fmt_idx = AHD20_SD_H960_2EX_Btype_PAL,
171
+ .field = V4L2_FIELD_INTERLACED,
172
+ },
173
+ {
183174 .width = 1280,
184175 .height = 720,
176
+ .max_fps = {
177
+ .numerator = 10000,
178
+ .denominator = 250000,
179
+ },
185180 .fmt_idx = AHD20_720P_25P_EX_Btype,
181
+ .field = V4L2_FIELD_NONE
186182 },
187183 {
188184 .width = 1920,
189185 .height = 1080,
186
+ .max_fps = {
187
+ .numerator = 10000,
188
+ .denominator = 250000,
189
+ },
190190 .fmt_idx = AHD20_1080P_25P,
191
+ .field = V4L2_FIELD_NONE
191192 },
192193 {
193194 .width = 2560,
194195 .height = 1440,
196
+ .max_fps = {
197
+ .numerator = 10000,
198
+ .denominator = 250000,
199
+ },
195200 .fmt_idx = AHD20_720P_25P,
201
+ .field = V4L2_FIELD_NONE
196202 }
197203 #endif
198204 };
....@@ -206,63 +212,6 @@
206212 static const s64 link_freq_menu_items[] = {
207213 JAGUAR1_LINK_FREQ
208214 };
209
-
210
-/* sensor register write */
211
-static int jaguar1_write(struct i2c_client *client, u8 reg, u8 val)
212
-{
213
- struct i2c_msg msg;
214
- u8 buf[2];
215
- int ret;
216
-
217
- dev_dbg(&client->dev, "write reg(0x%x val:0x%x)!\n", reg, val);
218
- buf[0] = reg & 0xFF;
219
- buf[1] = val;
220
-
221
- msg.addr = client->addr;
222
- msg.flags = client->flags;
223
- msg.buf = buf;
224
- msg.len = sizeof(buf);
225
-
226
- ret = i2c_transfer(client->adapter, &msg, 1);
227
- if (ret >= 0)
228
- return 0;
229
-
230
- dev_err(&client->dev,
231
- "jaguar1 write reg(0x%x val:0x%x) failed !\n", reg, val);
232
-
233
- return ret;
234
-}
235
-
236
-/* sensor register read */
237
-static int jaguar1_read(struct i2c_client *client, u8 reg, u8 *val)
238
-{
239
- struct i2c_msg msg[2];
240
- u8 buf[1];
241
- int ret;
242
-
243
- buf[0] = reg & 0xFF;
244
-
245
- msg[0].addr = client->addr;
246
- msg[0].flags = client->flags;
247
- msg[0].buf = buf;
248
- msg[0].len = sizeof(buf);
249
-
250
- msg[1].addr = client->addr;
251
- msg[1].flags = client->flags | I2C_M_RD;
252
- msg[1].buf = buf;
253
- msg[1].len = 1;
254
-
255
- ret = i2c_transfer(client->adapter, msg, 2);
256
- if (ret >= 0) {
257
- *val = buf[0];
258
- return 0;
259
- }
260
-
261
- dev_err(&client->dev, "jaguar1 read reg(0x%x) failed !\n", reg);
262
-
263
- return ret;
264
-}
265
-
266215 static int __jaguar1_power_on(struct jaguar1 *jaguar1)
267216 {
268217 u32 i;
....@@ -391,7 +340,7 @@
391340 struct jaguar1 *jaguar1 = to_jaguar1(sd);
392341 int ret = 0;
393342
394
- dev_info(&client->dev, "%s: on %d\n", __func__, on);
343
+ dev_dbg(&client->dev, "%s: on %d\n", __func__, on);
395344 mutex_lock(&jaguar1->mutex);
396345
397346 /* If the power state is not modified - no work to do. */
....@@ -402,12 +351,11 @@
402351 ret = __jaguar1_power_on(jaguar1);
403352 if (ret < 0)
404353 goto exit;
405
- jaguar1->power_on = true;
406354
355
+ jaguar1->power_on = true;
407356 } else {
408357 __jaguar1_power_off(jaguar1);
409358 jaguar1->power_on = false;
410
-
411359 }
412360
413361 exit:
....@@ -479,10 +427,9 @@
479427 format->colorspace = V4L2_COLORSPACE_SRGB;
480428 format->code = jaguar1_formats[0].code;
481429 jaguar1->frame_size = match;
482
- format->field = V4L2_FIELD_NONE;
430
+ format->field = match->field;
483431 }
484432
485
-static inline bool jaguar1_no_signal(struct v4l2_subdev *sd, u8 *novid);
486433 static int jaguar1_stream(struct v4l2_subdev *sd, int on)
487434 {
488435 struct i2c_client *client = v4l2_get_subdevdata(sd);
....@@ -491,7 +438,7 @@
491438 enum NC_VIVO_CH_FORMATDEF fmt_idx;
492439 int ch;
493440
494
- dev_info(&client->dev, "%s: on %d\n", __func__, on);
441
+ dev_dbg(&client->dev, "%s: on %d\n", __func__, on);
495442 mutex_lock(&jaguar1->mutex);
496443 on = !!on;
497444
....@@ -508,35 +455,8 @@
508455 video_init.ch_param[ch].interface = YUV_422;
509456 }
510457 jaguar1_start(&video_init);
511
-#ifdef WORK_QUEUE
512
- jaguar1->hot_plug = false;
513
- jaguar1->is_reset = 0;
514
- usleep_range(20000, 21000);
515
- /* get power on state first*/
516
- jaguar1_no_signal(sd, &jaguar1->last_detect_status);
517
- /* check hot plug state */
518
- if (jaguar1->plug_state_check.state_check_wq) {
519
- dev_info(&client->dev, "%s queue_delayed_work 1000ms", __func__);
520
- queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
521
- &jaguar1->plug_state_check.d_work,
522
- msecs_to_jiffies(1000));
523
- }
524
- jaguar1->timestamp0 = ktime_get_ns();
525
-#endif
526458 } else {
527459 jaguar1_stop();
528
-#ifdef WORK_QUEUE
529
- jaguar1->timestamp1 = ktime_get_ns();
530
- /* if stream off & on interval too short, do repower */
531
- if (div_u64((jaguar1->timestamp1 - jaguar1->timestamp0), 1000000) < 1200) {
532
- dev_info(&client->dev, "stream on/off too short, do power off & on!");
533
- __jaguar1_power_off(jaguar1);
534
- usleep_range(40000, 41000);
535
- __jaguar1_power_on(jaguar1);
536
- }
537
- cancel_delayed_work_sync(&jaguar1->plug_state_check.d_work);
538
- dev_info(&client->dev, "cancle_queue_delayed_work");
539
-#endif
540460 }
541461
542462 jaguar1->streaming = on;
....@@ -585,144 +505,28 @@
585505 return 0;
586506 }
587507
588
-/* indicate N4 no signal channel */
589
-static inline bool jaguar1_no_signal(struct v4l2_subdev *sd, u8 *novid)
508
+static int jaguar1_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
509
+ struct v4l2_mbus_config *cfg)
590510 {
591
- struct jaguar1 *jaguar1 = to_jaguar1(sd);
592
- struct i2c_client *client = jaguar1->client;
593
- u8 videoloss = 0;
594
- u8 temp = 0;
595
- int ch, ret;
596
- bool no_signal = false;
511
+ cfg->type = V4L2_MBUS_CSI2_DPHY;
512
+ cfg->flags = V4L2_MBUS_CSI2_4_LANE |
513
+ V4L2_MBUS_CSI2_CHANNELS;
597514
598
- jaguar1_write(client, 0xff, 0x00);
599
- for (ch = 0 ; ch < 4; ch++) {
600
- ret = jaguar1_read(client, 0xa4 + ch, &temp);
601
- if (ret < 0)
602
- dev_err(&client->dev, "Failed to read videoloss state!\n");
603
- videoloss |= (temp << ch);
604
- }
605
- *novid = videoloss;
606
- dev_dbg(&client->dev, "%s: video loss status:0x%x.\n", __func__, videoloss);
607
- if (videoloss == 0xf) {
608
- dev_dbg(&client->dev, "%s: all channels No Video detected.\n", __func__);
609
- no_signal = true;
610
- } else {
611
- dev_dbg(&client->dev, "%s: channel has some video detection.\n", __func__);
612
- no_signal = false;
613
- }
614
- return no_signal;
615
-}
616
-
617
-/* indicate N4 channel locked status */
618
-static inline bool jaguar1_sync(struct v4l2_subdev *sd, u8 *lock_st)
619
-{
620
- struct i2c_client *client = v4l2_get_subdevdata(sd);
621
- u8 video_lock_status = 0;
622
- u8 temp = 0;
623
- int ch, ret;
624
- bool has_sync = false;
625
-
626
- jaguar1_write(client, 0xff, 0x00);
627
- for (ch = 0 ; ch < 4; ch++) {
628
- ret = jaguar1_read(client, 0xd0 + ch, &temp);
629
- if (ret < 0)
630
- dev_err(&client->dev, "Failed to read LOCK status!\n");
631
- video_lock_status |= (temp << ch);
632
- }
633
-
634
- dev_dbg(&client->dev, "%s: video AGC LOCK status:0x%x.\n",
635
- __func__, video_lock_status);
636
- *lock_st = video_lock_status;
637
- if (video_lock_status) {
638
- dev_dbg(&client->dev, "%s: channel has AGC LOCK.\n", __func__);
639
- has_sync = true;
640
- } else {
641
- dev_dbg(&client->dev, "%s: channel has no AGC LOCK.\n", __func__);
642
- has_sync = false;
643
- }
644
- return has_sync;
645
-}
646
-
647
-#ifdef WORK_QUEUE
648
-static void jaguar1_plug_state_check_work(struct work_struct *work)
649
-{
650
- struct sensor_state_check_work *params_check =
651
- container_of(work, struct sensor_state_check_work, d_work.work);
652
- struct jaguar1 *jaguar1 =
653
- container_of(params_check, struct jaguar1, plug_state_check);
654
- struct i2c_client *client = jaguar1->client;
655
- struct v4l2_subdev *sd = &jaguar1->subdev;
656
- u8 novid_status = 0x00;
657
- u8 sync_status = 0x00;
658
-
659
- down(&jaguar1->reg_sem);
660
- jaguar1_no_signal(sd, &novid_status);
661
- jaguar1_sync(sd, &sync_status);
662
- up(&jaguar1->reg_sem);
663
- jaguar1->cur_detect_status = novid_status;
664
-
665
- /* detect state change to determine is there has plug motion */
666
- novid_status = jaguar1->cur_detect_status ^ jaguar1->last_detect_status;
667
- if (novid_status)
668
- jaguar1->hot_plug = true;
669
- else
670
- jaguar1->hot_plug = false;
671
- jaguar1->last_detect_status = jaguar1->cur_detect_status;
672
-
673
- if (jaguar1->hot_plug)
674
- dev_info(&client->dev, "%s has plug motion? (%s)", __func__,
675
- jaguar1->hot_plug ? "true" : "false");
676
- if (jaguar1->hot_plug) {
677
- dev_dbg(&client->dev, "queue_delayed_work 1500ms, if has hot plug motion.");
678
- queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
679
- &jaguar1->plug_state_check.d_work, msecs_to_jiffies(1500));
680
- jaguar1_write(client, 0xFF, 0x20);
681
- jaguar1_write(client, 0x00, 0x00);
682
- //jaguar1_write(client, 0x00, (sync_status << 4) | sync_status);
683
- usleep_range(3000, 5000);
684
- jaguar1_write(client, 0x00, 0xFF);
685
- } else {
686
- dev_dbg(&client->dev, "queue_delayed_work 100ms, if no hot plug motion.");
687
- queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
688
- &jaguar1->plug_state_check.d_work, msecs_to_jiffies(100));
689
- }
690
-}
691
-#endif
692
-
693
-static int jaguar1_g_input_status(struct v4l2_subdev *sd, u32 *status)
694
-{
695
- struct i2c_client *client = v4l2_get_subdevdata(sd);
696
- struct jaguar1 *jaguar1 = to_jaguar1(sd);
697
- int ret;
698
- u8 temp_novid;
699
- u8 temp_lock_st;
700
-
701
- if (!jaguar1->power_on) {
702
- ret = __jaguar1_power_on(jaguar1);
703
- if (ret < 0)
704
- goto exit;
705
- usleep_range(40000, 50000);
706
- jaguar1->power_on = true;
707
- }
708
-
709
- *status = 0;
710
- *status |= jaguar1_no_signal(sd, &temp_novid) ? V4L2_IN_ST_NO_SIGNAL : 0;
711
- *status |= jaguar1_sync(sd, &temp_lock_st) ? 0 : V4L2_IN_ST_NO_SYNC;
712
-
713
- dev_info(&client->dev, "%s: status = 0x%x\n", __func__, *status);
714
-
715
-exit:
716515 return 0;
717516 }
718517
719
-static int jaguar1_g_mbus_config(struct v4l2_subdev *sd,
720
- struct v4l2_mbus_config *cfg)
518
+static int jaguar1_enum_frame_interval(struct v4l2_subdev *sd,
519
+ struct v4l2_subdev_pad_config *cfg,
520
+ struct v4l2_subdev_frame_interval_enum *fie)
721521 {
722
- cfg->type = V4L2_MBUS_CSI2;
723
- cfg->flags = V4L2_MBUS_CSI2_4_LANE |
724
- V4L2_MBUS_CSI2_CHANNELS |
725
- V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
522
+ if (fie->index >= ARRAY_SIZE(jaguar1_framesizes))
523
+ return -EINVAL;
524
+
525
+ fie->code = jaguar1_formats[0].code;
526
+
527
+ fie->width = jaguar1_framesizes[fie->index].width;
528
+ fie->height = jaguar1_framesizes[fie->index].height;
529
+ fie->interval = jaguar1_framesizes[fie->index].max_fps;
726530
727531 return 0;
728532 }
....@@ -833,6 +637,19 @@
833637 return ret;
834638 }
835639
640
+static int jaguar1_g_frame_interval(struct v4l2_subdev *sd,
641
+ struct v4l2_subdev_frame_interval *fi)
642
+{
643
+ struct jaguar1 *jaguar1 = to_jaguar1(sd);
644
+ const struct jaguar1_framesize *size = jaguar1->frame_size;
645
+
646
+ mutex_lock(&jaguar1->mutex);
647
+ fi->interval = size->max_fps;
648
+ mutex_unlock(&jaguar1->mutex);
649
+
650
+ return 0;
651
+}
652
+
836653 static void jaguar1_get_module_inf(struct jaguar1 *jaguar1,
837654 struct rkmodule_inf *inf)
838655 {
....@@ -843,67 +660,17 @@
843660 strlcpy(inf->base.lens, jaguar1->len_name, sizeof(inf->base.lens));
844661 }
845662
846
-static void jaguar1_get_vicap_rst_inf(struct jaguar1 *jaguar1,
847
- struct rkmodule_vicap_reset_info *rst_info)
848
-{
849
- struct i2c_client *client = jaguar1->client;
850
-
851
- rst_info->is_reset = jaguar1->hot_plug;
852
- jaguar1->hot_plug = false;
853
- rst_info->src = RKCIF_RESET_SRC_ERR_HOTPLUG;
854
- if (rst_info->is_reset)
855
- dev_info(&client->dev, "%s: rst_info->is_reset:%d.\n",
856
- __func__, rst_info->is_reset);
857
-}
858
-
859
-static void jaguar1_set_vicap_rst_inf(struct jaguar1 *jaguar1,
860
- struct rkmodule_vicap_reset_info rst_info)
861
-{
862
- jaguar1->is_reset = rst_info.is_reset;
863
- jaguar1->hot_plug = rst_info.is_reset;
864
-}
865
-
866
-static void jaguar1_set_streaming(struct jaguar1 *jaguar1, int on)
867
-{
868
- struct i2c_client *client = jaguar1->client;
869
-
870
-
871
- dev_info(&client->dev, "%s: on: %d\n", __func__, on);
872
- down(&jaguar1->reg_sem);
873
- if (on) {
874
- /* enter mipi clk normal operation */
875
- jaguar1_write(client, 0xff, 0x21);
876
- jaguar1_write(client, 0x46, 0x00);
877
- } else {
878
- /* enter mipi clk powerdown */
879
- jaguar1_write(client, 0xff, 0x21);
880
- jaguar1_write(client, 0x46, 0x01);
881
- }
882
- up(&jaguar1->reg_sem);
883
-}
884
-
885663 static long jaguar1_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
886664 {
887665 struct jaguar1 *jaguar1 = to_jaguar1(sd);
888666 long ret = 0;
889
- u32 stream = 0;
890667
891668 switch (cmd) {
892669 case RKMODULE_GET_MODULE_INFO:
893670 jaguar1_get_module_inf(jaguar1, (struct rkmodule_inf *)arg);
894671 break;
895
- case RKMODULE_GET_VICAP_RST_INFO:
896
- jaguar1_get_vicap_rst_inf(jaguar1, (struct rkmodule_vicap_reset_info *)arg);
897
- break;
898
- case RKMODULE_SET_VICAP_RST_INFO:
899
- jaguar1_set_vicap_rst_inf(jaguar1, *(struct rkmodule_vicap_reset_info *)arg);
900
- break;
901672 case RKMODULE_GET_START_STREAM_SEQ:
902673 *(int *)arg = RKMODULE_START_STREAM_FRONT;
903
- break;
904
- case RKMODULE_SET_QUICK_STREAM:
905
- stream = *((u32 *)arg);
906
- jaguar1_set_streaming(jaguar1, !!stream);
907674 break;
908675 default:
909676 ret = -ENOTTY;
....@@ -920,10 +687,8 @@
920687 void __user *up = compat_ptr(arg);
921688 struct rkmodule_inf *inf;
922689 struct rkmodule_awb_cfg *cfg;
923
- struct rkmodule_vicap_reset_info *vicap_rst_inf;
924690 long ret;
925691 int *seq;
926
- u32 stream = 0;
927692
928693 switch (cmd) {
929694 case RKMODULE_GET_MODULE_INFO:
....@@ -955,35 +720,6 @@
955720 ret = -EFAULT;
956721 kfree(cfg);
957722 break;
958
- case RKMODULE_GET_VICAP_RST_INFO:
959
- vicap_rst_inf = kzalloc(sizeof(*vicap_rst_inf), GFP_KERNEL);
960
- if (!vicap_rst_inf) {
961
- ret = -ENOMEM;
962
- return ret;
963
- }
964
-
965
- ret = jaguar1_ioctl(sd, cmd, vicap_rst_inf);
966
- if (!ret) {
967
- ret = copy_to_user(up, vicap_rst_inf, sizeof(*vicap_rst_inf));
968
- if (ret)
969
- ret = -EFAULT;
970
- }
971
- kfree(vicap_rst_inf);
972
- break;
973
- case RKMODULE_SET_VICAP_RST_INFO:
974
- vicap_rst_inf = kzalloc(sizeof(*vicap_rst_inf), GFP_KERNEL);
975
- if (!vicap_rst_inf) {
976
- ret = -ENOMEM;
977
- return ret;
978
- }
979
-
980
- ret = copy_from_user(vicap_rst_inf, up, sizeof(*vicap_rst_inf));
981
- if (!ret)
982
- ret = jaguar1_ioctl(sd, cmd, vicap_rst_inf);
983
- else
984
- ret = -EFAULT;
985
- kfree(vicap_rst_inf);
986
- break;
987723 case RKMODULE_GET_START_STREAM_SEQ:
988724 seq = kzalloc(sizeof(*seq), GFP_KERNEL);
989725 if (!seq) {
....@@ -998,13 +734,6 @@
998734 ret = -EFAULT;
999735 }
1000736 kfree(seq);
1001
- break;
1002
- case RKMODULE_SET_QUICK_STREAM:
1003
- ret = copy_from_user(&stream, up, sizeof(u32));
1004
- if (!ret)
1005
- ret = jaguar1_ioctl(sd, cmd, &stream);
1006
- else
1007
- ret = -EFAULT;
1008737 break;
1009738 default:
1010739 ret = -ENOIOCTLCMD;
....@@ -1041,16 +770,17 @@
1041770 };
1042771
1043772 static const struct v4l2_subdev_video_ops jaguar1_video_ops = {
1044
- .g_input_status = jaguar1_g_input_status,
1045773 .s_stream = jaguar1_stream,
1046
- .g_mbus_config = jaguar1_g_mbus_config,
774
+ .g_frame_interval = jaguar1_g_frame_interval,
1047775 };
1048776
1049777 static const struct v4l2_subdev_pad_ops jaguar1_subdev_pad_ops = {
1050778 .enum_mbus_code = jaguar1_enum_mbus_code,
1051779 .enum_frame_size = jaguar1_enum_frame_sizes,
780
+ .enum_frame_interval = jaguar1_enum_frame_interval,
1052781 .get_fmt = jaguar1_get_fmt,
1053782 .set_fmt = jaguar1_set_fmt,
783
+ .get_mbus_config = jaguar1_g_mbus_config,
1054784 };
1055785
1056786 static const struct v4l2_subdev_core_ops jaguar1_core_ops = {
....@@ -1248,9 +978,13 @@
1248978 sd = &jaguar1->subdev;
1249979 v4l2_i2c_subdev_init(sd, client, &jaguar1_subdev_ops);
1250980 ret = jaguar1_initialize_controls(jaguar1);
981
+ if (ret) {
982
+ dev_err(dev, "Failed to initialize controls jaguar1\n");
983
+ return ret;
984
+ }
1251985
1252986 __jaguar1_power_on(jaguar1);
1253
- ret |= jaguar1_init(i2c_adapter_id(client->adapter));
987
+ ret = jaguar1_init(i2c_adapter_id(client->adapter));
1254988 if (ret) {
1255989 dev_err(dev, "Failed to init jaguar1\n");
1256990 __jaguar1_power_off(jaguar1);
....@@ -1258,7 +992,7 @@
1258992
1259993 return ret;
1260994 }
1261
- sema_init(&jaguar1->reg_sem, 1);
995
+
1262996 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
1263997 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1264998 #endif
....@@ -1298,22 +1032,8 @@
12981032 pm_runtime_enable(dev);
12991033 pm_runtime_idle(dev);
13001034
1301
-#ifdef WORK_QUEUE
1302
- /* init work_queue for state_check */
1303
- INIT_DELAYED_WORK(&jaguar1->plug_state_check.d_work, jaguar1_plug_state_check_work);
1304
- jaguar1->plug_state_check.state_check_wq =
1305
- create_singlethread_workqueue("jaguar1_work_queue");
1306
- if (jaguar1->plug_state_check.state_check_wq == NULL) {
1307
- dev_err(dev, "%s(%d): %s create failed.\n", __func__, __LINE__,
1308
- "jaguar1_work_queue");
1309
- }
1310
- jaguar1->cur_detect_status = 0x0;
1311
- jaguar1->last_detect_status = 0x0;
1312
- jaguar1->hot_plug = false;
1313
- jaguar1->is_reset = 0;
1314
-
1315
-#endif
1316
-
1035
+ v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
1036
+ client->addr << 1, client->adapter->name);
13171037 return 0;
13181038
13191039 err_power_off:
....@@ -1340,10 +1060,7 @@
13401060 if (!pm_runtime_status_suspended(&client->dev))
13411061 __jaguar1_power_off(jaguar1);
13421062 pm_runtime_set_suspended(&client->dev);
1343
-#ifdef WORK_QUEUE
1344
- if (jaguar1->plug_state_check.state_check_wq != NULL)
1345
- destroy_workqueue(jaguar1->plug_state_check.state_check_wq);
1346
-#endif
1063
+
13471064 return 0;
13481065 }
13491066
....@@ -1371,17 +1088,20 @@
13711088 .id_table = jaguar1_match_id,
13721089 };
13731090
1374
-static int __init sensor_mod_init(void)
1091
+int nvp6324_sensor_mod_init(void)
13751092 {
13761093 return i2c_add_driver(&jaguar1_i2c_driver);
13771094 }
1095
+
1096
+#ifndef CONFIG_VIDEO_REVERSE_IMAGE
1097
+device_initcall_sync(nvp6324_sensor_mod_init);
1098
+#endif
13781099
13791100 static void __exit sensor_mod_exit(void)
13801101 {
13811102 i2c_del_driver(&jaguar1_i2c_driver);
13821103 }
13831104
1384
-device_initcall_sync(sensor_mod_init);
13851105 module_exit(sensor_mod_exit);
13861106
13871107 MODULE_DESCRIPTION("jaguar1 sensor driver");