From 95099d4622f8cb224d94e314c7a8e0df60b13f87 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Sat, 09 Dec 2023 08:38:01 +0000
Subject: [PATCH] enable docker ppp

---
 kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c |  468 +++++++++++----------------------------------------------
 1 files changed, 94 insertions(+), 374 deletions(-)

diff --git a/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c b/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c
index d1faaf0..1538a91 100644
--- a/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c
+++ b/kernel/drivers/media/i2c/jaguar1_drv/jaguar1_v4l2.c
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * jaguar1 driver
- *
- * V0.0X01.0X01 add workqueue to detect ahd state.
+ * V0.0X01.0X00 first version.
+ * V0.0X01.0X01 fix kernel5.10 compile error.
  *
  */
 
@@ -39,18 +39,7 @@
 #include "jaguar1_video_eq.h"
 #include "jaguar1_mipi.h"
 #include "jaguar1_drv.h"
-
-#define WORK_QUEUE
-
-#ifdef WORK_QUEUE
-#include <linux/workqueue.h>
-
-struct sensor_state_check_work {
-	struct workqueue_struct *state_check_wq;
-	struct delayed_work d_work;
-};
-
-#endif
+#include "jaguar1_v4l2.h"
 
 #define DRIVER_VERSION				KERNEL_VERSION(0, 0x01, 0x1)
 
@@ -81,14 +70,6 @@
 
 /* #define FORCE_720P */
 
-enum jaguar1_max_pad {
-	PAD0,
-	PAD1,
-	PAD2,
-	PAD3,
-	PAD_MAX,
-};
-
 struct jaguar1_gpio {
 	int pltfrm_gpio;
 	const char *label;
@@ -113,18 +94,14 @@
 struct jaguar1_framesize {
 	u16 width;
 	u16 height;
+	struct v4l2_fract max_fps;
 	enum NC_VIVO_CH_FORMATDEF fmt_idx;
+	__u32 field;
 };
 
 struct jaguar1_default_rect {
 	unsigned int width;
 	unsigned int height;
-};
-
-enum jaguar1_hot_plug_state {
-	PLUG_IN = 0,
-	PLUG_OUT,
-	PLUG_STATE_MAX,
 };
 
 struct jaguar1 {
@@ -157,16 +134,6 @@
 	const struct jaguar1_framesize *frame_size;
 	int streaming;
 	struct jaguar1_default_rect defrect;
-#ifdef WORK_QUEUE
-	struct sensor_state_check_work plug_state_check;
-	u8 cur_detect_status;
-	u8 last_detect_status;
-	u64 timestamp0;
-	u64 timestamp1;
-#endif
-	bool hot_plug;
-	u8 is_reset;
-	struct semaphore reg_sem;
 };
 
 #define to_jaguar1(sd) container_of(sd, struct jaguar1, subdev)
@@ -176,23 +143,62 @@
 	{
 		.width		= 2560,
 		.height		= 1440,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 250000,
+		},
 		.fmt_idx	= AHD20_720P_25P,
 	}
 #else
 	{
+		.width		= 960,
+		.height		= 480,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 250000,
+		},
+		.fmt_idx	= AHD20_SD_H960_2EX_Btype_NT,
+		.field = V4L2_FIELD_INTERLACED,
+	},
+	{
+		.width		= 960,
+		.height		= 576,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 300000,
+		},
+		.fmt_idx	= AHD20_SD_H960_2EX_Btype_PAL,
+		.field = V4L2_FIELD_INTERLACED,
+	},
+	{
 		.width		= 1280,
 		.height		= 720,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 250000,
+		},
 		.fmt_idx	= AHD20_720P_25P_EX_Btype,
+		.field = V4L2_FIELD_NONE
 	},
 	{
 		.width		= 1920,
 		.height		= 1080,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 250000,
+		},
 		.fmt_idx	= AHD20_1080P_25P,
+		.field = V4L2_FIELD_NONE
 	},
 	{
 		.width		= 2560,
 		.height		= 1440,
+		.max_fps = {
+			.numerator = 10000,
+			.denominator = 250000,
+		},
 		.fmt_idx	= AHD20_720P_25P,
+		.field = V4L2_FIELD_NONE
 	}
 #endif
 };
@@ -206,63 +212,6 @@
 static const s64 link_freq_menu_items[] = {
 	JAGUAR1_LINK_FREQ
 };
-
-/* sensor register write */
-static int jaguar1_write(struct i2c_client *client, u8 reg, u8 val)
-{
-	struct i2c_msg msg;
-	u8 buf[2];
-	int ret;
-
-	dev_dbg(&client->dev, "write reg(0x%x val:0x%x)!\n", reg, val);
-	buf[0] = reg & 0xFF;
-	buf[1] = val;
-
-	msg.addr = client->addr;
-	msg.flags = client->flags;
-	msg.buf = buf;
-	msg.len = sizeof(buf);
-
-	ret = i2c_transfer(client->adapter, &msg, 1);
-	if (ret >= 0)
-		return 0;
-
-	dev_err(&client->dev,
-		"jaguar1 write reg(0x%x val:0x%x) failed !\n", reg, val);
-
-	return ret;
-}
-
-/* sensor register read */
-static int jaguar1_read(struct i2c_client *client, u8 reg, u8 *val)
-{
-	struct i2c_msg msg[2];
-	u8 buf[1];
-	int ret;
-
-	buf[0] = reg & 0xFF;
-
-	msg[0].addr = client->addr;
-	msg[0].flags = client->flags;
-	msg[0].buf = buf;
-	msg[0].len = sizeof(buf);
-
-	msg[1].addr = client->addr;
-	msg[1].flags = client->flags | I2C_M_RD;
-	msg[1].buf = buf;
-	msg[1].len = 1;
-
-	ret = i2c_transfer(client->adapter, msg, 2);
-	if (ret >= 0) {
-		*val = buf[0];
-		return 0;
-	}
-
-	dev_err(&client->dev, "jaguar1 read reg(0x%x) failed !\n", reg);
-
-	return ret;
-}
-
 static int __jaguar1_power_on(struct jaguar1 *jaguar1)
 {
 	u32 i;
@@ -391,7 +340,7 @@
 	struct jaguar1 *jaguar1 = to_jaguar1(sd);
 	int ret = 0;
 
-	dev_info(&client->dev, "%s: on %d\n", __func__, on);
+	dev_dbg(&client->dev, "%s: on %d\n", __func__, on);
 	mutex_lock(&jaguar1->mutex);
 
 	/* If the power state is not modified - no work to do. */
@@ -402,12 +351,11 @@
 		ret = __jaguar1_power_on(jaguar1);
 		if (ret < 0)
 			goto exit;
-		jaguar1->power_on = true;
 
+		jaguar1->power_on = true;
 	} else {
 		__jaguar1_power_off(jaguar1);
 		jaguar1->power_on = false;
-
 	}
 
 exit:
@@ -479,10 +427,9 @@
 	format->colorspace = V4L2_COLORSPACE_SRGB;
 	format->code = jaguar1_formats[0].code;
 	jaguar1->frame_size = match;
-	format->field = V4L2_FIELD_NONE;
+	format->field = match->field;
 }
 
-static inline bool jaguar1_no_signal(struct v4l2_subdev *sd, u8 *novid);
 static int jaguar1_stream(struct v4l2_subdev *sd, int on)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -491,7 +438,7 @@
 	enum NC_VIVO_CH_FORMATDEF fmt_idx;
 	int ch;
 
-	dev_info(&client->dev, "%s: on %d\n", __func__, on);
+	dev_dbg(&client->dev, "%s: on %d\n", __func__, on);
 	mutex_lock(&jaguar1->mutex);
 	on = !!on;
 
@@ -508,35 +455,8 @@
 			video_init.ch_param[ch].interface = YUV_422;
 		}
 		jaguar1_start(&video_init);
-#ifdef WORK_QUEUE
-		jaguar1->hot_plug = false;
-		jaguar1->is_reset = 0;
-		usleep_range(20000, 21000);
-		/* get power on state first*/
-		jaguar1_no_signal(sd, &jaguar1->last_detect_status);
-		/* check hot plug state */
-		if (jaguar1->plug_state_check.state_check_wq) {
-			dev_info(&client->dev, "%s queue_delayed_work 1000ms", __func__);
-			queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
-					   &jaguar1->plug_state_check.d_work,
-					   msecs_to_jiffies(1000));
-		}
-		jaguar1->timestamp0 = ktime_get_ns();
-#endif
 	} else {
 		jaguar1_stop();
-#ifdef WORK_QUEUE
-		jaguar1->timestamp1 = ktime_get_ns();
-		/* if stream off & on interval too short, do repower */
-		if (div_u64((jaguar1->timestamp1 - jaguar1->timestamp0), 1000000) < 1200) {
-			dev_info(&client->dev, "stream on/off too short, do power off & on!");
-			__jaguar1_power_off(jaguar1);
-			usleep_range(40000, 41000);
-			__jaguar1_power_on(jaguar1);
-		}
-		cancel_delayed_work_sync(&jaguar1->plug_state_check.d_work);
-		dev_info(&client->dev, "cancle_queue_delayed_work");
-#endif
 	}
 
 	jaguar1->streaming = on;
@@ -585,144 +505,28 @@
 	return 0;
 }
 
-/* indicate N4 no signal channel */
-static inline bool jaguar1_no_signal(struct v4l2_subdev *sd, u8 *novid)
+static int jaguar1_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
+				 struct v4l2_mbus_config *cfg)
 {
-	struct jaguar1 *jaguar1 = to_jaguar1(sd);
-	struct i2c_client *client = jaguar1->client;
-	u8 videoloss = 0;
-	u8 temp = 0;
-	int ch, ret;
-	bool no_signal = false;
+	cfg->type = V4L2_MBUS_CSI2_DPHY;
+	cfg->flags = V4L2_MBUS_CSI2_4_LANE |
+		     V4L2_MBUS_CSI2_CHANNELS;
 
-	jaguar1_write(client, 0xff, 0x00);
-	for (ch = 0 ; ch < 4; ch++) {
-		ret = jaguar1_read(client, 0xa4 + ch, &temp);
-		if (ret < 0)
-			dev_err(&client->dev, "Failed to read videoloss state!\n");
-		videoloss |= (temp << ch);
-	}
-	*novid = videoloss;
-	dev_dbg(&client->dev, "%s: video loss status:0x%x.\n", __func__, videoloss);
-	if (videoloss == 0xf) {
-		dev_dbg(&client->dev, "%s: all channels No Video detected.\n", __func__);
-		no_signal = true;
-	} else {
-		dev_dbg(&client->dev, "%s: channel has some video detection.\n", __func__);
-		no_signal = false;
-	}
-	return no_signal;
-}
-
-/* indicate N4 channel locked status */
-static inline bool jaguar1_sync(struct v4l2_subdev *sd, u8 *lock_st)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u8 video_lock_status = 0;
-	u8 temp = 0;
-	int ch, ret;
-	bool has_sync = false;
-
-	jaguar1_write(client, 0xff, 0x00);
-	for (ch = 0 ; ch < 4; ch++) {
-		ret = jaguar1_read(client, 0xd0 + ch, &temp);
-		if (ret < 0)
-			dev_err(&client->dev, "Failed to read LOCK status!\n");
-		video_lock_status |= (temp << ch);
-	}
-
-	dev_dbg(&client->dev, "%s: video AGC LOCK status:0x%x.\n",
-			__func__, video_lock_status);
-	*lock_st = video_lock_status;
-	if (video_lock_status) {
-		dev_dbg(&client->dev, "%s: channel has AGC LOCK.\n", __func__);
-		has_sync = true;
-	} else {
-		dev_dbg(&client->dev, "%s: channel has no AGC LOCK.\n", __func__);
-		has_sync = false;
-	}
-	return has_sync;
-}
-
-#ifdef WORK_QUEUE
-static void jaguar1_plug_state_check_work(struct work_struct *work)
-{
-	struct sensor_state_check_work *params_check =
-		container_of(work, struct sensor_state_check_work, d_work.work);
-	struct jaguar1 *jaguar1 =
-		container_of(params_check, struct jaguar1, plug_state_check);
-	struct i2c_client *client = jaguar1->client;
-	struct v4l2_subdev *sd = &jaguar1->subdev;
-	u8 novid_status = 0x00;
-	u8 sync_status = 0x00;
-
-	down(&jaguar1->reg_sem);
-	jaguar1_no_signal(sd, &novid_status);
-	jaguar1_sync(sd, &sync_status);
-	up(&jaguar1->reg_sem);
-	jaguar1->cur_detect_status = novid_status;
-
-	/* detect state change to determine is there has plug motion */
-	novid_status = jaguar1->cur_detect_status ^ jaguar1->last_detect_status;
-	if (novid_status)
-		jaguar1->hot_plug = true;
-	else
-		jaguar1->hot_plug = false;
-	jaguar1->last_detect_status = jaguar1->cur_detect_status;
-
-	if (jaguar1->hot_plug)
-		dev_info(&client->dev, "%s has plug motion? (%s)", __func__,
-				jaguar1->hot_plug ? "true" : "false");
-	if (jaguar1->hot_plug) {
-		dev_dbg(&client->dev, "queue_delayed_work 1500ms, if has hot plug motion.");
-		queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
-				   &jaguar1->plug_state_check.d_work, msecs_to_jiffies(1500));
-		jaguar1_write(client, 0xFF, 0x20);
-		jaguar1_write(client, 0x00, 0x00);
-		//jaguar1_write(client, 0x00, (sync_status << 4) | sync_status);
-		usleep_range(3000, 5000);
-		jaguar1_write(client, 0x00, 0xFF);
-	} else {
-		dev_dbg(&client->dev, "queue_delayed_work 100ms, if no hot plug motion.");
-		queue_delayed_work(jaguar1->plug_state_check.state_check_wq,
-				   &jaguar1->plug_state_check.d_work, msecs_to_jiffies(100));
-	}
-}
-#endif
-
-static int jaguar1_g_input_status(struct v4l2_subdev *sd, u32 *status)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct jaguar1 *jaguar1 = to_jaguar1(sd);
-	int ret;
-	u8 temp_novid;
-	u8 temp_lock_st;
-
-	if (!jaguar1->power_on) {
-		ret = __jaguar1_power_on(jaguar1);
-		if (ret < 0)
-			goto exit;
-		usleep_range(40000, 50000);
-		jaguar1->power_on = true;
-	}
-
-	*status = 0;
-	*status |= jaguar1_no_signal(sd, &temp_novid) ? V4L2_IN_ST_NO_SIGNAL : 0;
-	*status |= jaguar1_sync(sd, &temp_lock_st) ? 0 : V4L2_IN_ST_NO_SYNC;
-
-	dev_info(&client->dev, "%s: status = 0x%x\n", __func__, *status);
-
-exit:
 	return 0;
 }
 
-static int jaguar1_g_mbus_config(struct v4l2_subdev *sd,
-				 struct v4l2_mbus_config *cfg)
+static int jaguar1_enum_frame_interval(struct v4l2_subdev *sd,
+		struct v4l2_subdev_pad_config *cfg,
+		struct v4l2_subdev_frame_interval_enum *fie)
 {
-	cfg->type = V4L2_MBUS_CSI2;
-	cfg->flags = V4L2_MBUS_CSI2_4_LANE |
-		     V4L2_MBUS_CSI2_CHANNELS |
-		     V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	if (fie->index >= ARRAY_SIZE(jaguar1_framesizes))
+		return -EINVAL;
+
+	fie->code = jaguar1_formats[0].code;
+
+	fie->width = jaguar1_framesizes[fie->index].width;
+	fie->height = jaguar1_framesizes[fie->index].height;
+	fie->interval = jaguar1_framesizes[fie->index].max_fps;
 
 	return 0;
 }
@@ -833,6 +637,19 @@
 	return ret;
 }
 
+static int jaguar1_g_frame_interval(struct v4l2_subdev *sd,
+				    struct v4l2_subdev_frame_interval *fi)
+{
+	struct jaguar1 *jaguar1 = to_jaguar1(sd);
+	const struct jaguar1_framesize *size = jaguar1->frame_size;
+
+	mutex_lock(&jaguar1->mutex);
+	fi->interval = size->max_fps;
+	mutex_unlock(&jaguar1->mutex);
+
+	return 0;
+}
+
 static void jaguar1_get_module_inf(struct jaguar1 *jaguar1,
 				   struct rkmodule_inf *inf)
 {
@@ -843,67 +660,17 @@
 	strlcpy(inf->base.lens, jaguar1->len_name, sizeof(inf->base.lens));
 }
 
-static void jaguar1_get_vicap_rst_inf(struct jaguar1 *jaguar1,
-				   struct rkmodule_vicap_reset_info *rst_info)
-{
-	struct i2c_client *client = jaguar1->client;
-
-	rst_info->is_reset = jaguar1->hot_plug;
-	jaguar1->hot_plug = false;
-	rst_info->src = RKCIF_RESET_SRC_ERR_HOTPLUG;
-	if (rst_info->is_reset)
-		dev_info(&client->dev, "%s: rst_info->is_reset:%d.\n",
-				 __func__, rst_info->is_reset);
-}
-
-static void jaguar1_set_vicap_rst_inf(struct jaguar1 *jaguar1,
-				   struct rkmodule_vicap_reset_info rst_info)
-{
-	jaguar1->is_reset = rst_info.is_reset;
-	jaguar1->hot_plug = rst_info.is_reset;
-}
-
-static void jaguar1_set_streaming(struct jaguar1 *jaguar1, int on)
-{
-	struct i2c_client *client = jaguar1->client;
-
-
-	dev_info(&client->dev, "%s: on: %d\n", __func__, on);
-	down(&jaguar1->reg_sem);
-	if (on) {
-		/* enter mipi clk normal operation */
-		jaguar1_write(client, 0xff, 0x21);
-		jaguar1_write(client, 0x46, 0x00);
-	} else {
-		/* enter mipi clk powerdown */
-		jaguar1_write(client, 0xff, 0x21);
-		jaguar1_write(client, 0x46, 0x01);
-	}
-	up(&jaguar1->reg_sem);
-}
-
 static long jaguar1_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 {
 	struct jaguar1 *jaguar1 = to_jaguar1(sd);
 	long ret = 0;
-	u32 stream = 0;
 
 	switch (cmd) {
 	case RKMODULE_GET_MODULE_INFO:
 		jaguar1_get_module_inf(jaguar1, (struct rkmodule_inf *)arg);
 		break;
-	case RKMODULE_GET_VICAP_RST_INFO:
-		jaguar1_get_vicap_rst_inf(jaguar1, (struct rkmodule_vicap_reset_info *)arg);
-		break;
-	case RKMODULE_SET_VICAP_RST_INFO:
-		jaguar1_set_vicap_rst_inf(jaguar1, *(struct rkmodule_vicap_reset_info *)arg);
-		break;
 	case RKMODULE_GET_START_STREAM_SEQ:
 		*(int *)arg = RKMODULE_START_STREAM_FRONT;
-		break;
-	case RKMODULE_SET_QUICK_STREAM:
-		stream = *((u32 *)arg);
-		jaguar1_set_streaming(jaguar1, !!stream);
 		break;
 	default:
 		ret = -ENOTTY;
@@ -920,10 +687,8 @@
 	void __user *up = compat_ptr(arg);
 	struct rkmodule_inf *inf;
 	struct rkmodule_awb_cfg *cfg;
-	struct rkmodule_vicap_reset_info *vicap_rst_inf;
 	long ret;
 	int *seq;
-	u32 stream = 0;
 
 	switch (cmd) {
 	case RKMODULE_GET_MODULE_INFO:
@@ -955,35 +720,6 @@
 			ret = -EFAULT;
 		kfree(cfg);
 		break;
-	case RKMODULE_GET_VICAP_RST_INFO:
-		vicap_rst_inf = kzalloc(sizeof(*vicap_rst_inf), GFP_KERNEL);
-		if (!vicap_rst_inf) {
-			ret = -ENOMEM;
-			return ret;
-		}
-
-		ret = jaguar1_ioctl(sd, cmd, vicap_rst_inf);
-		if (!ret) {
-			ret = copy_to_user(up, vicap_rst_inf, sizeof(*vicap_rst_inf));
-			if (ret)
-				ret = -EFAULT;
-		}
-		kfree(vicap_rst_inf);
-		break;
-	case RKMODULE_SET_VICAP_RST_INFO:
-		vicap_rst_inf = kzalloc(sizeof(*vicap_rst_inf), GFP_KERNEL);
-		if (!vicap_rst_inf) {
-			ret = -ENOMEM;
-			return ret;
-		}
-
-		ret = copy_from_user(vicap_rst_inf, up, sizeof(*vicap_rst_inf));
-		if (!ret)
-			ret = jaguar1_ioctl(sd, cmd, vicap_rst_inf);
-		else
-			ret = -EFAULT;
-		kfree(vicap_rst_inf);
-		break;
 	case RKMODULE_GET_START_STREAM_SEQ:
 		seq = kzalloc(sizeof(*seq), GFP_KERNEL);
 		if (!seq) {
@@ -998,13 +734,6 @@
 				ret = -EFAULT;
 		}
 		kfree(seq);
-		break;
-	case RKMODULE_SET_QUICK_STREAM:
-		ret = copy_from_user(&stream, up, sizeof(u32));
-		if (!ret)
-			ret = jaguar1_ioctl(sd, cmd, &stream);
-		else
-			ret = -EFAULT;
 		break;
 	default:
 		ret = -ENOIOCTLCMD;
@@ -1041,16 +770,17 @@
 };
 
 static const struct v4l2_subdev_video_ops jaguar1_video_ops = {
-	.g_input_status = jaguar1_g_input_status,
 	.s_stream = jaguar1_stream,
-	.g_mbus_config = jaguar1_g_mbus_config,
+	.g_frame_interval = jaguar1_g_frame_interval,
 };
 
 static const struct v4l2_subdev_pad_ops jaguar1_subdev_pad_ops = {
 	.enum_mbus_code = jaguar1_enum_mbus_code,
 	.enum_frame_size = jaguar1_enum_frame_sizes,
+	.enum_frame_interval = jaguar1_enum_frame_interval,
 	.get_fmt = jaguar1_get_fmt,
 	.set_fmt = jaguar1_set_fmt,
+	.get_mbus_config = jaguar1_g_mbus_config,
 };
 
 static const struct v4l2_subdev_core_ops jaguar1_core_ops = {
@@ -1248,9 +978,13 @@
 	sd = &jaguar1->subdev;
 	v4l2_i2c_subdev_init(sd, client, &jaguar1_subdev_ops);
 	ret = jaguar1_initialize_controls(jaguar1);
+	if (ret) {
+		dev_err(dev, "Failed to initialize controls jaguar1\n");
+		return ret;
+	}
 
 	__jaguar1_power_on(jaguar1);
-	ret |= jaguar1_init(i2c_adapter_id(client->adapter));
+	ret = jaguar1_init(i2c_adapter_id(client->adapter));
 	if (ret) {
 		dev_err(dev, "Failed to init jaguar1\n");
 		__jaguar1_power_off(jaguar1);
@@ -1258,7 +992,7 @@
 
 		return ret;
 	}
-	sema_init(&jaguar1->reg_sem, 1);
+
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 #endif
@@ -1298,22 +1032,8 @@
 	pm_runtime_enable(dev);
 	pm_runtime_idle(dev);
 
-#ifdef WORK_QUEUE
-	/* init work_queue for state_check */
-	INIT_DELAYED_WORK(&jaguar1->plug_state_check.d_work, jaguar1_plug_state_check_work);
-	jaguar1->plug_state_check.state_check_wq =
-		create_singlethread_workqueue("jaguar1_work_queue");
-	if (jaguar1->plug_state_check.state_check_wq == NULL) {
-		dev_err(dev, "%s(%d): %s create failed.\n", __func__, __LINE__,
-			"jaguar1_work_queue");
-	}
-	jaguar1->cur_detect_status = 0x0;
-	jaguar1->last_detect_status = 0x0;
-	jaguar1->hot_plug = false;
-	jaguar1->is_reset = 0;
-
-#endif
-
+	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
+			client->addr << 1, client->adapter->name);
 	return 0;
 
 err_power_off:
@@ -1340,10 +1060,7 @@
 	if (!pm_runtime_status_suspended(&client->dev))
 		__jaguar1_power_off(jaguar1);
 	pm_runtime_set_suspended(&client->dev);
-#ifdef WORK_QUEUE
-	if (jaguar1->plug_state_check.state_check_wq != NULL)
-		destroy_workqueue(jaguar1->plug_state_check.state_check_wq);
-#endif
+
 	return 0;
 }
 
@@ -1371,17 +1088,20 @@
 	.id_table	= jaguar1_match_id,
 };
 
-static int __init sensor_mod_init(void)
+int nvp6324_sensor_mod_init(void)
 {
 	return i2c_add_driver(&jaguar1_i2c_driver);
 }
+
+#ifndef CONFIG_VIDEO_REVERSE_IMAGE
+device_initcall_sync(nvp6324_sensor_mod_init);
+#endif
 
 static void __exit sensor_mod_exit(void)
 {
 	i2c_del_driver(&jaguar1_i2c_driver);
 }
 
-device_initcall_sync(sensor_mod_init);
 module_exit(sensor_mod_exit);
 
 MODULE_DESCRIPTION("jaguar1 sensor driver");

--
Gitblit v1.6.2