| .. | .. |
|---|
| 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 | */ |
|---|
| .. | .. |
|---|
| 13 | 13 | #include "techpoint_tp2855.h" |
|---|
| 14 | 14 | #include "techpoint_tp2815.h" |
|---|
| 15 | 15 | |
|---|
| 16 | | -static struct semaphore reg_sem; |
|---|
| 16 | +static DEFINE_MUTEX(reg_sem); |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | int techpoint_write_reg(struct i2c_client *client, u8 reg, u8 val) |
|---|
| 19 | 19 | { |
|---|
| .. | .. |
|---|
| 126 | 126 | techpoint->chip_id = CHIP_TP9950; |
|---|
| 127 | 127 | techpoint->input_type = TECHPOINT_MIPI; |
|---|
| 128 | 128 | return 0; |
|---|
| 129 | | - } else { |
|---|
| 130 | | - dev_info(&client->dev, "techpoint check chip id failed !\n"); |
|---|
| 131 | 129 | } |
|---|
| 132 | 130 | |
|---|
| 131 | + dev_info(&client->dev, "techpoint check chip id failed !\n"); |
|---|
| 133 | 132 | return -1; |
|---|
| 134 | 133 | } |
|---|
| 135 | 134 | |
|---|
| .. | .. |
|---|
| 138 | 137 | if (check_chip_id(techpoint)) |
|---|
| 139 | 138 | return -1; |
|---|
| 140 | 139 | |
|---|
| 141 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 140 | + if (techpoint->chip_id == CHIP_TP9930) |
|---|
| 142 | 141 | tp9930_initialize(techpoint); |
|---|
| 143 | | - } else if (techpoint->chip_id == CHIP_TP2855) { |
|---|
| 142 | + else if (techpoint->chip_id == CHIP_TP2855) |
|---|
| 144 | 143 | tp2855_initialize(techpoint); |
|---|
| 145 | | - } else if (techpoint->chip_id == CHIP_TP9950) { |
|---|
| 144 | + else if (techpoint->chip_id == CHIP_TP9950) |
|---|
| 146 | 145 | tp9950_initialize(techpoint); |
|---|
| 147 | | - } |
|---|
| 148 | | - |
|---|
| 149 | | - sema_init(®_sem, 1); |
|---|
| 150 | 146 | |
|---|
| 151 | 147 | return 0; |
|---|
| 152 | 148 | } |
|---|
| .. | .. |
|---|
| 159 | 155 | int need_reset_wait = -1; |
|---|
| 160 | 156 | |
|---|
| 161 | 157 | if (techpoint->power_on) { |
|---|
| 162 | | - down(®_sem); |
|---|
| 158 | + mutex_lock(®_sem); |
|---|
| 163 | 159 | if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 164 | 160 | tp9930_get_all_input_status(techpoint, |
|---|
| 165 | 161 | techpoint->detect_status); |
|---|
| .. | .. |
|---|
| 173 | 169 | tp2855_set_decoder_mode(client, i, |
|---|
| 174 | 170 | techpoint->detect_status[i]); |
|---|
| 175 | 171 | } |
|---|
| 176 | | - up(®_sem); |
|---|
| 172 | + mutex_unlock(®_sem); |
|---|
| 177 | 173 | techpoint->do_reset = 0; |
|---|
| 178 | 174 | } |
|---|
| 179 | 175 | |
|---|
| 180 | 176 | while (!kthread_should_stop()) { |
|---|
| 181 | | - down(®_sem); |
|---|
| 177 | + mutex_lock(®_sem); |
|---|
| 182 | 178 | if (techpoint->power_on) { |
|---|
| 183 | 179 | for (i = 0; i < PAD_MAX; i++) { |
|---|
| 184 | 180 | if (techpoint->chip_id == CHIP_TP9930) |
|---|
| .. | .. |
|---|
| 220 | 216 | "trigger reset time up\n"); |
|---|
| 221 | 217 | } |
|---|
| 222 | 218 | } |
|---|
| 223 | | - up(®_sem); |
|---|
| 219 | + mutex_unlock(®_sem); |
|---|
| 224 | 220 | set_current_state(TASK_INTERRUPTIBLE); |
|---|
| 225 | 221 | schedule_timeout(msecs_to_jiffies(200)); |
|---|
| 226 | 222 | } |
|---|
| .. | .. |
|---|
| 260 | 256 | enum techpoint_support_reso reso = 0xff; |
|---|
| 261 | 257 | struct i2c_client *client = techpoint->client; |
|---|
| 262 | 258 | |
|---|
| 263 | | - down(®_sem); |
|---|
| 259 | + mutex_lock(®_sem); |
|---|
| 264 | 260 | |
|---|
| 265 | 261 | for (ch = 0; ch < PAD_MAX; ch++) { |
|---|
| 266 | 262 | if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| .. | .. |
|---|
| 277 | 273 | tp9950_set_channel_reso(client, 0, reso); |
|---|
| 278 | 274 | } |
|---|
| 279 | 275 | |
|---|
| 280 | | - up(®_sem); |
|---|
| 276 | + mutex_unlock(®_sem); |
|---|
| 281 | 277 | |
|---|
| 282 | 278 | return 0; |
|---|
| 283 | 279 | } |
|---|
| .. | .. |
|---|
| 290 | 286 | enum techpoint_support_reso reso = 0xff; |
|---|
| 291 | 287 | struct i2c_client *client = techpoint->client; |
|---|
| 292 | 288 | |
|---|
| 293 | | - down(®_sem); |
|---|
| 289 | + mutex_lock(®_sem); |
|---|
| 294 | 290 | |
|---|
| 295 | 291 | for (ch = 0; ch < PAD_MAX; ch++) { |
|---|
| 296 | 292 | if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| .. | .. |
|---|
| 341 | 337 | } |
|---|
| 342 | 338 | } |
|---|
| 343 | 339 | |
|---|
| 344 | | - up(®_sem); |
|---|
| 340 | + mutex_unlock(®_sem); |
|---|
| 345 | 341 | } |
|---|
| 346 | 342 | |
|---|
| 347 | 343 | void techpoint_get_vc_fmt_inf(struct techpoint *techpoint, |
|---|
| 348 | 344 | struct rkmodule_vc_fmt_info *inf) |
|---|
| 349 | 345 | { |
|---|
| 350 | | - down(®_sem); |
|---|
| 346 | + mutex_lock(®_sem); |
|---|
| 351 | 347 | |
|---|
| 352 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 348 | + if (techpoint->chip_id == CHIP_TP9930) |
|---|
| 353 | 349 | tp9930_pll_reset(techpoint->client); |
|---|
| 354 | | - } |
|---|
| 355 | 350 | |
|---|
| 356 | 351 | techpoint_write_array(techpoint->client, |
|---|
| 357 | 352 | techpoint->cur_video_mode->common_reg_list, |
|---|
| 358 | 353 | techpoint->cur_video_mode->common_reg_size); |
|---|
| 359 | 354 | |
|---|
| 360 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 355 | + if (techpoint->chip_id == CHIP_TP9930) |
|---|
| 361 | 356 | tp9930_do_reset_pll(techpoint->client); |
|---|
| 362 | | - } |
|---|
| 363 | 357 | |
|---|
| 364 | | - up(®_sem); |
|---|
| 358 | + mutex_unlock(®_sem); |
|---|
| 365 | 359 | |
|---|
| 366 | 360 | __techpoint_get_vc_fmt_inf(techpoint, inf); |
|---|
| 367 | 361 | } |
|---|
| .. | .. |
|---|
| 374 | 368 | |
|---|
| 375 | 369 | memset(inf, 0, sizeof(*inf)); |
|---|
| 376 | 370 | |
|---|
| 377 | | - down(®_sem); |
|---|
| 371 | + mutex_lock(®_sem); |
|---|
| 378 | 372 | |
|---|
| 379 | 373 | for (ch = 0; ch < 4; ch++) { |
|---|
| 380 | 374 | if (techpoint->chip_id == CHIP_TP9930) |
|---|
| .. | .. |
|---|
| 387 | 381 | inf->detect_status |= detect_status << ch; |
|---|
| 388 | 382 | } |
|---|
| 389 | 383 | |
|---|
| 390 | | - up(®_sem); |
|---|
| 384 | + mutex_unlock(®_sem); |
|---|
| 391 | 385 | } |
|---|
| 392 | 386 | |
|---|
| 393 | 387 | void techpoint_set_quick_stream(struct techpoint *techpoint, u32 stream) |
|---|
| 394 | 388 | { |
|---|
| 395 | | - if (techpoint->chip_id == CHIP_TP2855) { |
|---|
| 389 | + if (techpoint->chip_id == CHIP_TP2855) |
|---|
| 396 | 390 | tp2855_set_quick_stream(techpoint, stream); |
|---|
| 397 | | - } |
|---|
| 398 | 391 | } |
|---|
| 399 | 392 | |
|---|
| 400 | 393 | int techpoint_start_video_stream(struct techpoint *techpoint) |
|---|
| .. | .. |
|---|
| 402 | 395 | int ret = 0; |
|---|
| 403 | 396 | struct i2c_client *client = techpoint->client; |
|---|
| 404 | 397 | |
|---|
| 405 | | - down(®_sem); |
|---|
| 406 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 398 | + mutex_lock(®_sem); |
|---|
| 399 | + if (techpoint->chip_id == CHIP_TP9930) |
|---|
| 407 | 400 | tp9930_pll_reset(techpoint->client); |
|---|
| 408 | | - } |
|---|
| 409 | | - up(®_sem); |
|---|
| 401 | + mutex_unlock(®_sem); |
|---|
| 410 | 402 | |
|---|
| 411 | 403 | auto_detect_channel_fmt(techpoint); |
|---|
| 412 | 404 | ret = techpoint_write_array(techpoint->client, |
|---|
| .. | .. |
|---|
| 414 | 406 | techpoint->cur_video_mode->common_reg_size); |
|---|
| 415 | 407 | if (ret) { |
|---|
| 416 | 408 | dev_err(&client->dev, |
|---|
| 417 | | - "techpoint_start_video_stream common_reg_list failed"); |
|---|
| 409 | + "%s common_reg_list failed", __func__); |
|---|
| 418 | 410 | return ret; |
|---|
| 419 | 411 | } |
|---|
| 420 | 412 | |
|---|
| 421 | | - down(®_sem); |
|---|
| 422 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 413 | + mutex_lock(®_sem); |
|---|
| 414 | + if (techpoint->chip_id == CHIP_TP9930) |
|---|
| 423 | 415 | tp9930_do_reset_pll(techpoint->client); |
|---|
| 424 | | - } |
|---|
| 425 | | - up(®_sem); |
|---|
| 416 | + mutex_unlock(®_sem); |
|---|
| 426 | 417 | |
|---|
| 427 | 418 | usleep_range(500 * 1000, 1000 * 1000); |
|---|
| 428 | 419 | |
|---|
| .. | .. |
|---|
| 434 | 425 | int techpoint_stop_video_stream(struct techpoint *techpoint) |
|---|
| 435 | 426 | { |
|---|
| 436 | 427 | detect_thread_stop(techpoint); |
|---|
| 437 | | - |
|---|
| 438 | | - if (techpoint->chip_id == CHIP_TP9930) { |
|---|
| 439 | | - |
|---|
| 440 | | - } else if (techpoint->chip_id == CHIP_TP2855) { |
|---|
| 441 | | - |
|---|
| 442 | | - } |
|---|
| 443 | 428 | return 0; |
|---|
| 444 | 429 | } |
|---|