.. | .. |
---|
2 | 2 | /* |
---|
3 | 3 | * techpoint dev driver |
---|
4 | 4 | * |
---|
5 | | - * Copyright (C) 2022 Rockchip Electronics Co., Ltd. |
---|
| 5 | + * Copyright (C) 2023 Rockchip Electronics Co., Ltd. |
---|
6 | 6 | * |
---|
7 | 7 | * V0.0X01.0X00 first version. |
---|
8 | 8 | */ |
---|
.. | .. |
---|
12 | 12 | #include "techpoint_tp9950.h" |
---|
13 | 13 | #include "techpoint_tp2855.h" |
---|
14 | 14 | #include "techpoint_tp2815.h" |
---|
| 15 | +#include "techpoint_tp9951.h" |
---|
15 | 16 | |
---|
16 | | -static struct semaphore reg_sem; |
---|
| 17 | +static DEFINE_MUTEX(reg_sem); |
---|
17 | 18 | |
---|
18 | 19 | int techpoint_write_reg(struct i2c_client *client, u8 reg, u8 val) |
---|
19 | 20 | { |
---|
.. | .. |
---|
99 | 100 | techpoint_read_reg(client, CHIP_ID_L_REG, &chip_id_l); |
---|
100 | 101 | dev_err(dev, "chip_id_h:0x%2x chip_id_l:0x%2x\n", chip_id_h, chip_id_l); |
---|
101 | 102 | if (chip_id_h == TP9930_CHIP_ID_H_VALUE && |
---|
102 | | - chip_id_l == TP9930_CHIP_ID_L_VALUE) { |
---|
| 103 | + chip_id_l == TP9930_CHIP_ID_L_VALUE) { //tp2832 |
---|
103 | 104 | dev_info(&client->dev, |
---|
104 | 105 | "techpoint check chip id CHIP_TP9930 !\n"); |
---|
105 | 106 | techpoint->chip_id = CHIP_TP9930; |
---|
106 | 107 | techpoint->input_type = TECHPOINT_DVP_BT1120; |
---|
107 | 108 | return 0; |
---|
108 | 109 | } else if (chip_id_h == TP2855_CHIP_ID_H_VALUE && |
---|
109 | | - chip_id_l == TP2855_CHIP_ID_L_VALUE) { |
---|
| 110 | + chip_id_l == TP2855_CHIP_ID_L_VALUE) { //tp2855 |
---|
110 | 111 | dev_info(&client->dev, |
---|
111 | 112 | "techpoint check chip id CHIP_TP2855 !\n"); |
---|
112 | 113 | techpoint->chip_id = CHIP_TP2855; |
---|
113 | 114 | techpoint->input_type = TECHPOINT_MIPI; |
---|
114 | 115 | return 0; |
---|
115 | 116 | } else if (chip_id_h == TP2815_CHIP_ID_H_VALUE && |
---|
116 | | - chip_id_l == TP2815_CHIP_ID_L_VALUE) { |
---|
| 117 | + chip_id_l == TP2815_CHIP_ID_L_VALUE) { //tp2815 |
---|
117 | 118 | dev_info(&client->dev, |
---|
118 | 119 | "techpoint check chip id CHIP_TP2815 !\n"); |
---|
119 | 120 | techpoint->chip_id = CHIP_TP2855; |
---|
120 | 121 | techpoint->input_type = TECHPOINT_MIPI; |
---|
121 | 122 | return 0; |
---|
122 | 123 | } else if (chip_id_h == TP9950_CHIP_ID_H_VALUE && |
---|
123 | | - chip_id_l == TP9950_CHIP_ID_L_VALUE) { |
---|
| 124 | + chip_id_l == TP9950_CHIP_ID_L_VALUE) { //tp2850 |
---|
124 | 125 | dev_info(&client->dev, |
---|
125 | 126 | "techpoint check chip id CHIP_TP9950 !\n"); |
---|
126 | 127 | techpoint->chip_id = CHIP_TP9950; |
---|
127 | 128 | techpoint->input_type = TECHPOINT_MIPI; |
---|
128 | 129 | return 0; |
---|
129 | | - } else { |
---|
130 | | - dev_info(&client->dev, "techpoint check chip id failed !\n"); |
---|
| 130 | + } else if (chip_id_h == TP9951_CHIP_ID_H_VALUE && |
---|
| 131 | + chip_id_l == TP9951_CHIP_ID_L_VALUE) { //tp2860 |
---|
| 132 | + dev_info(&client->dev, |
---|
| 133 | + "techpoint check chip id CHIP_TP9951 !\n"); |
---|
| 134 | + techpoint->chip_id = CHIP_TP9951; |
---|
| 135 | + techpoint->input_type = TECHPOINT_MIPI; |
---|
| 136 | + return 0; |
---|
131 | 137 | } |
---|
132 | 138 | |
---|
| 139 | + dev_info(&client->dev, "techpoint check chip id failed !\n"); |
---|
133 | 140 | return -1; |
---|
134 | 141 | } |
---|
135 | 142 | |
---|
.. | .. |
---|
138 | 145 | if (check_chip_id(techpoint)) |
---|
139 | 146 | return -1; |
---|
140 | 147 | |
---|
141 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
| 148 | + if (techpoint->chip_id == CHIP_TP9930) |
---|
142 | 149 | tp9930_initialize(techpoint); |
---|
143 | | - } else if (techpoint->chip_id == CHIP_TP2855) { |
---|
| 150 | + else if (techpoint->chip_id == CHIP_TP2855) |
---|
144 | 151 | tp2855_initialize(techpoint); |
---|
145 | | - } else if (techpoint->chip_id == CHIP_TP9950) { |
---|
| 152 | + else if (techpoint->chip_id == CHIP_TP9950) |
---|
146 | 153 | tp9950_initialize(techpoint); |
---|
147 | | - } |
---|
148 | | - |
---|
149 | | - sema_init(®_sem, 1); |
---|
| 154 | + else if (techpoint->chip_id == CHIP_TP9951) |
---|
| 155 | + tp9951_initialize(techpoint); |
---|
150 | 156 | |
---|
151 | 157 | return 0; |
---|
152 | 158 | } |
---|
.. | .. |
---|
159 | 165 | int need_reset_wait = -1; |
---|
160 | 166 | |
---|
161 | 167 | if (techpoint->power_on) { |
---|
162 | | - down(®_sem); |
---|
| 168 | + mutex_lock(®_sem); |
---|
163 | 169 | if (techpoint->chip_id == CHIP_TP9930) { |
---|
164 | 170 | tp9930_get_all_input_status(techpoint, |
---|
165 | 171 | techpoint->detect_status); |
---|
.. | .. |
---|
173 | 179 | tp2855_set_decoder_mode(client, i, |
---|
174 | 180 | techpoint->detect_status[i]); |
---|
175 | 181 | } |
---|
176 | | - up(®_sem); |
---|
| 182 | + mutex_unlock(®_sem); |
---|
177 | 183 | techpoint->do_reset = 0; |
---|
178 | 184 | } |
---|
179 | 185 | |
---|
180 | 186 | while (!kthread_should_stop()) { |
---|
181 | | - down(®_sem); |
---|
| 187 | + mutex_lock(®_sem); |
---|
182 | 188 | if (techpoint->power_on) { |
---|
183 | 189 | for (i = 0; i < PAD_MAX; i++) { |
---|
184 | 190 | if (techpoint->chip_id == CHIP_TP9930) |
---|
.. | .. |
---|
188 | 194 | else if (techpoint->chip_id == CHIP_TP2855) |
---|
189 | 195 | detect_status = |
---|
190 | 196 | tp2855_get_channel_input_status |
---|
| 197 | + (techpoint, i); |
---|
| 198 | + else if (techpoint->chip_id == CHIP_TP9951) |
---|
| 199 | + detect_status = |
---|
| 200 | + tp9951_get_channel_input_status |
---|
191 | 201 | (techpoint, i); |
---|
192 | 202 | |
---|
193 | 203 | if (techpoint->detect_status[i] != |
---|
.. | .. |
---|
206 | 216 | else if (techpoint->chip_id == CHIP_TP2855) |
---|
207 | 217 | tp2855_set_decoder_mode(client, i, detect_status); |
---|
208 | 218 | |
---|
209 | | - techpoint->detect_status[i] = |
---|
210 | | - detect_status; |
---|
| 219 | + techpoint->detect_status[i] = detect_status; |
---|
211 | 220 | need_reset_wait = 5; |
---|
212 | 221 | } |
---|
213 | 222 | } |
---|
.. | .. |
---|
220 | 229 | "trigger reset time up\n"); |
---|
221 | 230 | } |
---|
222 | 231 | } |
---|
223 | | - up(®_sem); |
---|
| 232 | + mutex_unlock(®_sem); |
---|
224 | 233 | set_current_state(TASK_INTERRUPTIBLE); |
---|
225 | 234 | schedule_timeout(msecs_to_jiffies(200)); |
---|
226 | 235 | } |
---|
.. | .. |
---|
260 | 269 | enum techpoint_support_reso reso = 0xff; |
---|
261 | 270 | struct i2c_client *client = techpoint->client; |
---|
262 | 271 | |
---|
263 | | - down(®_sem); |
---|
| 272 | + mutex_lock(®_sem); |
---|
264 | 273 | |
---|
265 | 274 | for (ch = 0; ch < PAD_MAX; ch++) { |
---|
266 | 275 | if (techpoint->chip_id == CHIP_TP9930) { |
---|
.. | .. |
---|
277 | 286 | tp9950_set_channel_reso(client, 0, reso); |
---|
278 | 287 | } |
---|
279 | 288 | |
---|
280 | | - up(®_sem); |
---|
| 289 | + if (techpoint->chip_id == CHIP_TP9951) { |
---|
| 290 | + reso = tp9951_get_channel_reso(client, 0); |
---|
| 291 | + tp9951_set_channel_reso(client, 0, reso); |
---|
| 292 | + } |
---|
| 293 | + |
---|
| 294 | + mutex_unlock(®_sem); |
---|
281 | 295 | |
---|
282 | 296 | return 0; |
---|
283 | 297 | } |
---|
.. | .. |
---|
290 | 304 | enum techpoint_support_reso reso = 0xff; |
---|
291 | 305 | struct i2c_client *client = techpoint->client; |
---|
292 | 306 | |
---|
293 | | - down(®_sem); |
---|
| 307 | + mutex_lock(®_sem); |
---|
294 | 308 | |
---|
295 | 309 | for (ch = 0; ch < PAD_MAX; ch++) { |
---|
296 | 310 | if (techpoint->chip_id == CHIP_TP9930) { |
---|
.. | .. |
---|
341 | 355 | } |
---|
342 | 356 | } |
---|
343 | 357 | |
---|
344 | | - up(®_sem); |
---|
| 358 | + mutex_unlock(®_sem); |
---|
345 | 359 | } |
---|
346 | 360 | |
---|
347 | 361 | void techpoint_get_vc_fmt_inf(struct techpoint *techpoint, |
---|
348 | 362 | struct rkmodule_vc_fmt_info *inf) |
---|
349 | 363 | { |
---|
350 | | - down(®_sem); |
---|
| 364 | + mutex_lock(®_sem); |
---|
351 | 365 | |
---|
352 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
| 366 | + if (techpoint->chip_id == CHIP_TP9930) |
---|
353 | 367 | tp9930_pll_reset(techpoint->client); |
---|
354 | | - } |
---|
355 | 368 | |
---|
356 | 369 | techpoint_write_array(techpoint->client, |
---|
357 | 370 | techpoint->cur_video_mode->common_reg_list, |
---|
358 | 371 | techpoint->cur_video_mode->common_reg_size); |
---|
359 | 372 | |
---|
360 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
| 373 | + if (techpoint->chip_id == CHIP_TP9930) |
---|
361 | 374 | tp9930_do_reset_pll(techpoint->client); |
---|
362 | | - } |
---|
363 | 375 | |
---|
364 | | - up(®_sem); |
---|
| 376 | + mutex_unlock(®_sem); |
---|
365 | 377 | |
---|
366 | 378 | __techpoint_get_vc_fmt_inf(techpoint, inf); |
---|
367 | 379 | } |
---|
.. | .. |
---|
374 | 386 | |
---|
375 | 387 | memset(inf, 0, sizeof(*inf)); |
---|
376 | 388 | |
---|
377 | | - down(®_sem); |
---|
| 389 | + mutex_lock(®_sem); |
---|
378 | 390 | |
---|
379 | 391 | for (ch = 0; ch < 4; ch++) { |
---|
380 | 392 | if (techpoint->chip_id == CHIP_TP9930) |
---|
.. | .. |
---|
387 | 399 | inf->detect_status |= detect_status << ch; |
---|
388 | 400 | } |
---|
389 | 401 | |
---|
390 | | - up(®_sem); |
---|
| 402 | + mutex_unlock(®_sem); |
---|
391 | 403 | } |
---|
392 | 404 | |
---|
393 | 405 | void techpoint_set_quick_stream(struct techpoint *techpoint, u32 stream) |
---|
394 | 406 | { |
---|
395 | | - if (techpoint->chip_id == CHIP_TP2855) { |
---|
| 407 | + if (techpoint->chip_id == CHIP_TP2855) |
---|
396 | 408 | tp2855_set_quick_stream(techpoint, stream); |
---|
397 | | - } |
---|
398 | 409 | } |
---|
399 | 410 | |
---|
400 | 411 | int techpoint_start_video_stream(struct techpoint *techpoint) |
---|
.. | .. |
---|
402 | 413 | int ret = 0; |
---|
403 | 414 | struct i2c_client *client = techpoint->client; |
---|
404 | 415 | |
---|
405 | | - down(®_sem); |
---|
406 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
| 416 | + mutex_lock(®_sem); |
---|
| 417 | + if (techpoint->chip_id == CHIP_TP9930) |
---|
407 | 418 | tp9930_pll_reset(techpoint->client); |
---|
408 | | - } |
---|
409 | | - up(®_sem); |
---|
| 419 | + mutex_unlock(®_sem); |
---|
410 | 420 | |
---|
411 | 421 | auto_detect_channel_fmt(techpoint); |
---|
412 | 422 | ret = techpoint_write_array(techpoint->client, |
---|
.. | .. |
---|
414 | 424 | techpoint->cur_video_mode->common_reg_size); |
---|
415 | 425 | if (ret) { |
---|
416 | 426 | dev_err(&client->dev, |
---|
417 | | - "techpoint_start_video_stream common_reg_list failed"); |
---|
| 427 | + "%s common_reg_list failed", __func__); |
---|
418 | 428 | return ret; |
---|
419 | 429 | } |
---|
420 | 430 | |
---|
421 | | - down(®_sem); |
---|
422 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
| 431 | + mutex_lock(®_sem); |
---|
| 432 | + if (techpoint->chip_id == CHIP_TP9930) |
---|
423 | 433 | tp9930_do_reset_pll(techpoint->client); |
---|
424 | | - } |
---|
425 | | - up(®_sem); |
---|
| 434 | + mutex_unlock(®_sem); |
---|
426 | 435 | |
---|
427 | 436 | usleep_range(500 * 1000, 1000 * 1000); |
---|
428 | 437 | |
---|
.. | .. |
---|
434 | 443 | int techpoint_stop_video_stream(struct techpoint *techpoint) |
---|
435 | 444 | { |
---|
436 | 445 | detect_thread_stop(techpoint); |
---|
437 | | - |
---|
438 | | - if (techpoint->chip_id == CHIP_TP9930) { |
---|
439 | | - |
---|
440 | | - } else if (techpoint->chip_id == CHIP_TP2855) { |
---|
441 | | - |
---|
442 | | - } |
---|
443 | 446 | return 0; |
---|
444 | 447 | } |
---|