1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * techpoint dev driver
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (C) 2023 Rockchip Electronics Co., Ltd.
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * V0.0X01.0X00 first version.
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #include "techpoint_dev.h"
11*4882a593Smuzhiyun #include "techpoint_tp9930.h"
12*4882a593Smuzhiyun #include "techpoint_tp9950.h"
13*4882a593Smuzhiyun #include "techpoint_tp2855.h"
14*4882a593Smuzhiyun #include "techpoint_tp2815.h"
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun static DEFINE_MUTEX(reg_sem);
17*4882a593Smuzhiyun
techpoint_write_reg(struct i2c_client * client,u8 reg,u8 val)18*4882a593Smuzhiyun int techpoint_write_reg(struct i2c_client *client, u8 reg, u8 val)
19*4882a593Smuzhiyun {
20*4882a593Smuzhiyun struct i2c_msg msg;
21*4882a593Smuzhiyun u8 buf[2];
22*4882a593Smuzhiyun int ret;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun buf[0] = reg & 0xFF;
25*4882a593Smuzhiyun buf[1] = val;
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun msg.addr = client->addr;
28*4882a593Smuzhiyun msg.flags = client->flags;
29*4882a593Smuzhiyun msg.buf = buf;
30*4882a593Smuzhiyun msg.len = sizeof(buf);
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun ret = i2c_transfer(client->adapter, &msg, 1);
33*4882a593Smuzhiyun if (ret >= 0) {
34*4882a593Smuzhiyun usleep_range(300, 400);
35*4882a593Smuzhiyun return 0;
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun dev_err(&client->dev,
39*4882a593Smuzhiyun "techpoint write reg(0x%x val:0x%x) failed !\n", reg, val);
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun return ret;
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun
techpoint_write_array(struct i2c_client * client,const struct regval * regs,int size)44*4882a593Smuzhiyun int techpoint_write_array(struct i2c_client *client,
45*4882a593Smuzhiyun const struct regval *regs, int size)
46*4882a593Smuzhiyun {
47*4882a593Smuzhiyun int i, ret = 0;
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun i = 0;
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun while (i < size) {
52*4882a593Smuzhiyun ret = techpoint_write_reg(client, regs[i].addr, regs[i].val);
53*4882a593Smuzhiyun if (ret) {
54*4882a593Smuzhiyun dev_err(&client->dev, "%s failed !\n", __func__);
55*4882a593Smuzhiyun break;
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun i++;
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun return ret;
61*4882a593Smuzhiyun }
62*4882a593Smuzhiyun
techpoint_read_reg(struct i2c_client * client,u8 reg,u8 * val)63*4882a593Smuzhiyun int techpoint_read_reg(struct i2c_client *client, u8 reg, u8 *val)
64*4882a593Smuzhiyun {
65*4882a593Smuzhiyun struct i2c_msg msg[2];
66*4882a593Smuzhiyun u8 buf[1];
67*4882a593Smuzhiyun int ret;
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun buf[0] = reg & 0xFF;
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun msg[0].addr = client->addr;
72*4882a593Smuzhiyun msg[0].flags = client->flags;
73*4882a593Smuzhiyun msg[0].buf = buf;
74*4882a593Smuzhiyun msg[0].len = sizeof(buf);
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun msg[1].addr = client->addr;
77*4882a593Smuzhiyun msg[1].flags = client->flags | I2C_M_RD;
78*4882a593Smuzhiyun msg[1].buf = buf;
79*4882a593Smuzhiyun msg[1].len = 1;
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun ret = i2c_transfer(client->adapter, msg, 2);
82*4882a593Smuzhiyun if (ret >= 0) {
83*4882a593Smuzhiyun *val = buf[0];
84*4882a593Smuzhiyun return 0;
85*4882a593Smuzhiyun }
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun dev_err(&client->dev, "techpoint read reg(0x%x) failed !\n", reg);
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun return ret;
90*4882a593Smuzhiyun }
91*4882a593Smuzhiyun
check_chip_id(struct techpoint * techpoint)92*4882a593Smuzhiyun static int check_chip_id(struct techpoint *techpoint)
93*4882a593Smuzhiyun {
94*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
95*4882a593Smuzhiyun struct device *dev = &client->dev;
96*4882a593Smuzhiyun unsigned char chip_id_h = 0xFF, chip_id_l = 0xFF;
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun techpoint_read_reg(client, CHIP_ID_H_REG, &chip_id_h);
99*4882a593Smuzhiyun techpoint_read_reg(client, CHIP_ID_L_REG, &chip_id_l);
100*4882a593Smuzhiyun dev_err(dev, "chip_id_h:0x%2x chip_id_l:0x%2x\n", chip_id_h, chip_id_l);
101*4882a593Smuzhiyun if (chip_id_h == TP9930_CHIP_ID_H_VALUE &&
102*4882a593Smuzhiyun chip_id_l == TP9930_CHIP_ID_L_VALUE) {
103*4882a593Smuzhiyun dev_info(&client->dev,
104*4882a593Smuzhiyun "techpoint check chip id CHIP_TP9930 !\n");
105*4882a593Smuzhiyun techpoint->chip_id = CHIP_TP9930;
106*4882a593Smuzhiyun techpoint->input_type = TECHPOINT_DVP_BT1120;
107*4882a593Smuzhiyun return 0;
108*4882a593Smuzhiyun } else if (chip_id_h == TP2855_CHIP_ID_H_VALUE &&
109*4882a593Smuzhiyun chip_id_l == TP2855_CHIP_ID_L_VALUE) {
110*4882a593Smuzhiyun dev_info(&client->dev,
111*4882a593Smuzhiyun "techpoint check chip id CHIP_TP2855 !\n");
112*4882a593Smuzhiyun techpoint->chip_id = CHIP_TP2855;
113*4882a593Smuzhiyun techpoint->input_type = TECHPOINT_MIPI;
114*4882a593Smuzhiyun return 0;
115*4882a593Smuzhiyun } else if (chip_id_h == TP2815_CHIP_ID_H_VALUE &&
116*4882a593Smuzhiyun chip_id_l == TP2815_CHIP_ID_L_VALUE) {
117*4882a593Smuzhiyun dev_info(&client->dev,
118*4882a593Smuzhiyun "techpoint check chip id CHIP_TP2815 !\n");
119*4882a593Smuzhiyun techpoint->chip_id = CHIP_TP2855;
120*4882a593Smuzhiyun techpoint->input_type = TECHPOINT_MIPI;
121*4882a593Smuzhiyun return 0;
122*4882a593Smuzhiyun } else if (chip_id_h == TP9950_CHIP_ID_H_VALUE &&
123*4882a593Smuzhiyun chip_id_l == TP9950_CHIP_ID_L_VALUE) {
124*4882a593Smuzhiyun dev_info(&client->dev,
125*4882a593Smuzhiyun "techpoint check chip id CHIP_TP9950 !\n");
126*4882a593Smuzhiyun techpoint->chip_id = CHIP_TP9950;
127*4882a593Smuzhiyun techpoint->input_type = TECHPOINT_MIPI;
128*4882a593Smuzhiyun return 0;
129*4882a593Smuzhiyun }
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun dev_info(&client->dev, "techpoint check chip id failed !\n");
132*4882a593Smuzhiyun return -1;
133*4882a593Smuzhiyun }
134*4882a593Smuzhiyun
techpoint_initialize_devices(struct techpoint * techpoint)135*4882a593Smuzhiyun int techpoint_initialize_devices(struct techpoint *techpoint)
136*4882a593Smuzhiyun {
137*4882a593Smuzhiyun if (check_chip_id(techpoint))
138*4882a593Smuzhiyun return -1;
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
141*4882a593Smuzhiyun tp9930_initialize(techpoint);
142*4882a593Smuzhiyun else if (techpoint->chip_id == CHIP_TP2855)
143*4882a593Smuzhiyun tp2855_initialize(techpoint);
144*4882a593Smuzhiyun else if (techpoint->chip_id == CHIP_TP9950)
145*4882a593Smuzhiyun tp9950_initialize(techpoint);
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun return 0;
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun
detect_thread_function(void * data)150*4882a593Smuzhiyun static int detect_thread_function(void *data)
151*4882a593Smuzhiyun {
152*4882a593Smuzhiyun struct techpoint *techpoint = (struct techpoint *)data;
153*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
154*4882a593Smuzhiyun u8 detect_status = 0, i;
155*4882a593Smuzhiyun int need_reset_wait = -1;
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun if (techpoint->power_on) {
158*4882a593Smuzhiyun mutex_lock(®_sem);
159*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930) {
160*4882a593Smuzhiyun tp9930_get_all_input_status(techpoint,
161*4882a593Smuzhiyun techpoint->detect_status);
162*4882a593Smuzhiyun for (i = 0; i < PAD_MAX; i++)
163*4882a593Smuzhiyun tp9930_set_decoder_mode(client, i,
164*4882a593Smuzhiyun techpoint->detect_status[i]);
165*4882a593Smuzhiyun } else if (techpoint->chip_id == CHIP_TP2855) {
166*4882a593Smuzhiyun tp2855_get_all_input_status(techpoint,
167*4882a593Smuzhiyun techpoint->detect_status);
168*4882a593Smuzhiyun for (i = 0; i < PAD_MAX; i++)
169*4882a593Smuzhiyun tp2855_set_decoder_mode(client, i,
170*4882a593Smuzhiyun techpoint->detect_status[i]);
171*4882a593Smuzhiyun }
172*4882a593Smuzhiyun mutex_unlock(®_sem);
173*4882a593Smuzhiyun techpoint->do_reset = 0;
174*4882a593Smuzhiyun }
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun while (!kthread_should_stop()) {
177*4882a593Smuzhiyun mutex_lock(®_sem);
178*4882a593Smuzhiyun if (techpoint->power_on) {
179*4882a593Smuzhiyun for (i = 0; i < PAD_MAX; i++) {
180*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
181*4882a593Smuzhiyun detect_status =
182*4882a593Smuzhiyun tp9930_get_channel_input_status
183*4882a593Smuzhiyun (techpoint, i);
184*4882a593Smuzhiyun else if (techpoint->chip_id == CHIP_TP2855)
185*4882a593Smuzhiyun detect_status =
186*4882a593Smuzhiyun tp2855_get_channel_input_status
187*4882a593Smuzhiyun (techpoint, i);
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun if (techpoint->detect_status[i] !=
190*4882a593Smuzhiyun detect_status) {
191*4882a593Smuzhiyun if (!detect_status)
192*4882a593Smuzhiyun dev_info(&client->dev,
193*4882a593Smuzhiyun "detect channel %d video plug out\n",
194*4882a593Smuzhiyun i);
195*4882a593Smuzhiyun else
196*4882a593Smuzhiyun dev_info(&client->dev,
197*4882a593Smuzhiyun "detect channel %d video plug in\n",
198*4882a593Smuzhiyun i);
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
201*4882a593Smuzhiyun tp9930_set_decoder_mode(client, i, detect_status);
202*4882a593Smuzhiyun else if (techpoint->chip_id == CHIP_TP2855)
203*4882a593Smuzhiyun tp2855_set_decoder_mode(client, i, detect_status);
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun techpoint->detect_status[i] =
206*4882a593Smuzhiyun detect_status;
207*4882a593Smuzhiyun need_reset_wait = 5;
208*4882a593Smuzhiyun }
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun if (need_reset_wait > 0) {
211*4882a593Smuzhiyun need_reset_wait--;
212*4882a593Smuzhiyun } else if (need_reset_wait == 0) {
213*4882a593Smuzhiyun need_reset_wait = -1;
214*4882a593Smuzhiyun techpoint->do_reset = 1;
215*4882a593Smuzhiyun dev_info(&client->dev,
216*4882a593Smuzhiyun "trigger reset time up\n");
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun }
219*4882a593Smuzhiyun mutex_unlock(®_sem);
220*4882a593Smuzhiyun set_current_state(TASK_INTERRUPTIBLE);
221*4882a593Smuzhiyun schedule_timeout(msecs_to_jiffies(200));
222*4882a593Smuzhiyun }
223*4882a593Smuzhiyun return 0;
224*4882a593Smuzhiyun }
225*4882a593Smuzhiyun
detect_thread_start(struct techpoint * techpoint)226*4882a593Smuzhiyun static int __maybe_unused detect_thread_start(struct techpoint *techpoint)
227*4882a593Smuzhiyun {
228*4882a593Smuzhiyun int ret = 0;
229*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun techpoint->detect_thread = kthread_create(detect_thread_function,
232*4882a593Smuzhiyun techpoint,
233*4882a593Smuzhiyun "techpoint_kthread");
234*4882a593Smuzhiyun if (IS_ERR(techpoint->detect_thread)) {
235*4882a593Smuzhiyun dev_err(&client->dev,
236*4882a593Smuzhiyun "kthread_create techpoint_kthread failed\n");
237*4882a593Smuzhiyun ret = PTR_ERR(techpoint->detect_thread);
238*4882a593Smuzhiyun techpoint->detect_thread = NULL;
239*4882a593Smuzhiyun return ret;
240*4882a593Smuzhiyun }
241*4882a593Smuzhiyun wake_up_process(techpoint->detect_thread);
242*4882a593Smuzhiyun return ret;
243*4882a593Smuzhiyun }
244*4882a593Smuzhiyun
detect_thread_stop(struct techpoint * techpoint)245*4882a593Smuzhiyun static int __maybe_unused detect_thread_stop(struct techpoint *techpoint)
246*4882a593Smuzhiyun {
247*4882a593Smuzhiyun if (techpoint->detect_thread)
248*4882a593Smuzhiyun kthread_stop(techpoint->detect_thread);
249*4882a593Smuzhiyun techpoint->detect_thread = NULL;
250*4882a593Smuzhiyun return 0;
251*4882a593Smuzhiyun }
252*4882a593Smuzhiyun
auto_detect_channel_fmt(struct techpoint * techpoint)253*4882a593Smuzhiyun static __maybe_unused int auto_detect_channel_fmt(struct techpoint *techpoint)
254*4882a593Smuzhiyun {
255*4882a593Smuzhiyun int ch = 0;
256*4882a593Smuzhiyun enum techpoint_support_reso reso = 0xff;
257*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun mutex_lock(®_sem);
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun for (ch = 0; ch < PAD_MAX; ch++) {
262*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930) {
263*4882a593Smuzhiyun reso = tp9930_get_channel_reso(client, ch);
264*4882a593Smuzhiyun tp9930_set_channel_reso(client, ch, reso);
265*4882a593Smuzhiyun } else if (techpoint->chip_id == CHIP_TP2855) {
266*4882a593Smuzhiyun reso = tp2855_get_channel_reso(client, ch);
267*4882a593Smuzhiyun tp2855_set_channel_reso(client, ch, reso);
268*4882a593Smuzhiyun }
269*4882a593Smuzhiyun }
270*4882a593Smuzhiyun
271*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9950) {
272*4882a593Smuzhiyun reso = tp9950_get_channel_reso(client, 0);
273*4882a593Smuzhiyun tp9950_set_channel_reso(client, 0, reso);
274*4882a593Smuzhiyun }
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun mutex_unlock(®_sem);
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun return 0;
279*4882a593Smuzhiyun }
280*4882a593Smuzhiyun
__techpoint_get_vc_fmt_inf(struct techpoint * techpoint,struct rkmodule_vc_fmt_info * inf)281*4882a593Smuzhiyun void __techpoint_get_vc_fmt_inf(struct techpoint *techpoint,
282*4882a593Smuzhiyun struct rkmodule_vc_fmt_info *inf)
283*4882a593Smuzhiyun {
284*4882a593Smuzhiyun int ch = 0;
285*4882a593Smuzhiyun int val = 0;
286*4882a593Smuzhiyun enum techpoint_support_reso reso = 0xff;
287*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun mutex_lock(®_sem);
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun for (ch = 0; ch < PAD_MAX; ch++) {
292*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930) {
293*4882a593Smuzhiyun reso = tp9930_get_channel_reso(client, ch);
294*4882a593Smuzhiyun techpoint->cur_video_mode->channel_reso[ch] = reso;
295*4882a593Smuzhiyun } else if (techpoint->chip_id == CHIP_TP2855) {
296*4882a593Smuzhiyun reso = tp2855_get_channel_reso(client, ch);
297*4882a593Smuzhiyun techpoint->cur_video_mode->channel_reso[ch] = reso;
298*4882a593Smuzhiyun }
299*4882a593Smuzhiyun val = reso;
300*4882a593Smuzhiyun switch (val) {
301*4882a593Smuzhiyun case TECHPOINT_S_RESO_1080P_30:
302*4882a593Smuzhiyun inf->width[ch] = 1920;
303*4882a593Smuzhiyun inf->height[ch] = 1080;
304*4882a593Smuzhiyun inf->fps[ch] = 30;
305*4882a593Smuzhiyun break;
306*4882a593Smuzhiyun case TECHPOINT_S_RESO_1080P_25:
307*4882a593Smuzhiyun inf->width[ch] = 1920;
308*4882a593Smuzhiyun inf->height[ch] = 1080;
309*4882a593Smuzhiyun inf->fps[ch] = 25;
310*4882a593Smuzhiyun break;
311*4882a593Smuzhiyun case TECHPOINT_S_RESO_720P_30:
312*4882a593Smuzhiyun inf->width[ch] = 1280;
313*4882a593Smuzhiyun inf->height[ch] = 720;
314*4882a593Smuzhiyun inf->fps[ch] = 30;
315*4882a593Smuzhiyun break;
316*4882a593Smuzhiyun case TECHPOINT_S_RESO_720P_25:
317*4882a593Smuzhiyun inf->width[ch] = 1280;
318*4882a593Smuzhiyun inf->height[ch] = 720;
319*4882a593Smuzhiyun inf->fps[ch] = 25;
320*4882a593Smuzhiyun break;
321*4882a593Smuzhiyun case TECHPOINT_S_RESO_SD:
322*4882a593Smuzhiyun inf->width[ch] = 720;
323*4882a593Smuzhiyun inf->height[ch] = 560;
324*4882a593Smuzhiyun inf->fps[ch] = 25;
325*4882a593Smuzhiyun break;
326*4882a593Smuzhiyun default:
327*4882a593Smuzhiyun #if DEF_1080P
328*4882a593Smuzhiyun inf->width[ch] = 1920;
329*4882a593Smuzhiyun inf->height[ch] = 1080;
330*4882a593Smuzhiyun inf->fps[ch] = 25;
331*4882a593Smuzhiyun #else
332*4882a593Smuzhiyun inf->width[ch] = 1280;
333*4882a593Smuzhiyun inf->height[ch] = 720;
334*4882a593Smuzhiyun inf->fps[ch] = 25;
335*4882a593Smuzhiyun #endif
336*4882a593Smuzhiyun break;
337*4882a593Smuzhiyun }
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun mutex_unlock(®_sem);
341*4882a593Smuzhiyun }
342*4882a593Smuzhiyun
techpoint_get_vc_fmt_inf(struct techpoint * techpoint,struct rkmodule_vc_fmt_info * inf)343*4882a593Smuzhiyun void techpoint_get_vc_fmt_inf(struct techpoint *techpoint,
344*4882a593Smuzhiyun struct rkmodule_vc_fmt_info *inf)
345*4882a593Smuzhiyun {
346*4882a593Smuzhiyun mutex_lock(®_sem);
347*4882a593Smuzhiyun
348*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
349*4882a593Smuzhiyun tp9930_pll_reset(techpoint->client);
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun techpoint_write_array(techpoint->client,
352*4882a593Smuzhiyun techpoint->cur_video_mode->common_reg_list,
353*4882a593Smuzhiyun techpoint->cur_video_mode->common_reg_size);
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
356*4882a593Smuzhiyun tp9930_do_reset_pll(techpoint->client);
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun mutex_unlock(®_sem);
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun __techpoint_get_vc_fmt_inf(techpoint, inf);
361*4882a593Smuzhiyun }
362*4882a593Smuzhiyun
techpoint_get_vc_hotplug_inf(struct techpoint * techpoint,struct rkmodule_vc_hotplug_info * inf)363*4882a593Smuzhiyun void techpoint_get_vc_hotplug_inf(struct techpoint *techpoint,
364*4882a593Smuzhiyun struct rkmodule_vc_hotplug_info *inf)
365*4882a593Smuzhiyun {
366*4882a593Smuzhiyun int ch = 0;
367*4882a593Smuzhiyun int detect_status = 0;
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun memset(inf, 0, sizeof(*inf));
370*4882a593Smuzhiyun
371*4882a593Smuzhiyun mutex_lock(®_sem);
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun for (ch = 0; ch < 4; ch++) {
374*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
375*4882a593Smuzhiyun detect_status =
376*4882a593Smuzhiyun tp9930_get_channel_input_status(techpoint, ch);
377*4882a593Smuzhiyun else if (techpoint->chip_id == CHIP_TP2855)
378*4882a593Smuzhiyun detect_status =
379*4882a593Smuzhiyun tp2855_get_channel_input_status(techpoint, ch);
380*4882a593Smuzhiyun
381*4882a593Smuzhiyun inf->detect_status |= detect_status << ch;
382*4882a593Smuzhiyun }
383*4882a593Smuzhiyun
384*4882a593Smuzhiyun mutex_unlock(®_sem);
385*4882a593Smuzhiyun }
386*4882a593Smuzhiyun
techpoint_set_quick_stream(struct techpoint * techpoint,u32 stream)387*4882a593Smuzhiyun void techpoint_set_quick_stream(struct techpoint *techpoint, u32 stream)
388*4882a593Smuzhiyun {
389*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP2855)
390*4882a593Smuzhiyun tp2855_set_quick_stream(techpoint, stream);
391*4882a593Smuzhiyun }
392*4882a593Smuzhiyun
techpoint_start_video_stream(struct techpoint * techpoint)393*4882a593Smuzhiyun int techpoint_start_video_stream(struct techpoint *techpoint)
394*4882a593Smuzhiyun {
395*4882a593Smuzhiyun int ret = 0;
396*4882a593Smuzhiyun struct i2c_client *client = techpoint->client;
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun mutex_lock(®_sem);
399*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
400*4882a593Smuzhiyun tp9930_pll_reset(techpoint->client);
401*4882a593Smuzhiyun mutex_unlock(®_sem);
402*4882a593Smuzhiyun
403*4882a593Smuzhiyun auto_detect_channel_fmt(techpoint);
404*4882a593Smuzhiyun ret = techpoint_write_array(techpoint->client,
405*4882a593Smuzhiyun techpoint->cur_video_mode->common_reg_list,
406*4882a593Smuzhiyun techpoint->cur_video_mode->common_reg_size);
407*4882a593Smuzhiyun if (ret) {
408*4882a593Smuzhiyun dev_err(&client->dev,
409*4882a593Smuzhiyun "%s common_reg_list failed", __func__);
410*4882a593Smuzhiyun return ret;
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun mutex_lock(®_sem);
414*4882a593Smuzhiyun if (techpoint->chip_id == CHIP_TP9930)
415*4882a593Smuzhiyun tp9930_do_reset_pll(techpoint->client);
416*4882a593Smuzhiyun mutex_unlock(®_sem);
417*4882a593Smuzhiyun
418*4882a593Smuzhiyun usleep_range(500 * 1000, 1000 * 1000);
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun detect_thread_start(techpoint);
421*4882a593Smuzhiyun
422*4882a593Smuzhiyun return 0;
423*4882a593Smuzhiyun }
424*4882a593Smuzhiyun
techpoint_stop_video_stream(struct techpoint * techpoint)425*4882a593Smuzhiyun int techpoint_stop_video_stream(struct techpoint *techpoint)
426*4882a593Smuzhiyun {
427*4882a593Smuzhiyun detect_thread_stop(techpoint);
428*4882a593Smuzhiyun return 0;
429*4882a593Smuzhiyun }
430