From 071106ecf68c401173c58808b1cf5f68cc50d390 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 05 Jan 2024 08:39:27 +0000
Subject: [PATCH] change wifi driver to cypress
---
kernel/drivers/media/i2c/techpoint/techpoint_dev.c | 101 ++++++++++++++++++++++++++------------------------
1 files changed, 52 insertions(+), 49 deletions(-)
diff --git a/kernel/drivers/media/i2c/techpoint/techpoint_dev.c b/kernel/drivers/media/i2c/techpoint/techpoint_dev.c
index 1354c15..5692fbc 100644
--- a/kernel/drivers/media/i2c/techpoint/techpoint_dev.c
+++ b/kernel/drivers/media/i2c/techpoint/techpoint_dev.c
@@ -2,7 +2,7 @@
/*
* techpoint dev driver
*
- * Copyright (C) 2022 Rockchip Electronics Co., Ltd.
+ * Copyright (C) 2023 Rockchip Electronics Co., Ltd.
*
* V0.0X01.0X00 first version.
*/
@@ -12,8 +12,9 @@
#include "techpoint_tp9950.h"
#include "techpoint_tp2855.h"
#include "techpoint_tp2815.h"
+#include "techpoint_tp9951.h"
-static struct semaphore reg_sem;
+static DEFINE_MUTEX(reg_sem);
int techpoint_write_reg(struct i2c_client *client, u8 reg, u8 val)
{
@@ -99,37 +100,43 @@
techpoint_read_reg(client, CHIP_ID_L_REG, &chip_id_l);
dev_err(dev, "chip_id_h:0x%2x chip_id_l:0x%2x\n", chip_id_h, chip_id_l);
if (chip_id_h == TP9930_CHIP_ID_H_VALUE &&
- chip_id_l == TP9930_CHIP_ID_L_VALUE) {
+ chip_id_l == TP9930_CHIP_ID_L_VALUE) { //tp2832
dev_info(&client->dev,
"techpoint check chip id CHIP_TP9930 !\n");
techpoint->chip_id = CHIP_TP9930;
techpoint->input_type = TECHPOINT_DVP_BT1120;
return 0;
} else if (chip_id_h == TP2855_CHIP_ID_H_VALUE &&
- chip_id_l == TP2855_CHIP_ID_L_VALUE) {
+ chip_id_l == TP2855_CHIP_ID_L_VALUE) { //tp2855
dev_info(&client->dev,
"techpoint check chip id CHIP_TP2855 !\n");
techpoint->chip_id = CHIP_TP2855;
techpoint->input_type = TECHPOINT_MIPI;
return 0;
} else if (chip_id_h == TP2815_CHIP_ID_H_VALUE &&
- chip_id_l == TP2815_CHIP_ID_L_VALUE) {
+ chip_id_l == TP2815_CHIP_ID_L_VALUE) { //tp2815
dev_info(&client->dev,
"techpoint check chip id CHIP_TP2815 !\n");
techpoint->chip_id = CHIP_TP2855;
techpoint->input_type = TECHPOINT_MIPI;
return 0;
} else if (chip_id_h == TP9950_CHIP_ID_H_VALUE &&
- chip_id_l == TP9950_CHIP_ID_L_VALUE) {
+ chip_id_l == TP9950_CHIP_ID_L_VALUE) { //tp2850
dev_info(&client->dev,
"techpoint check chip id CHIP_TP9950 !\n");
techpoint->chip_id = CHIP_TP9950;
techpoint->input_type = TECHPOINT_MIPI;
return 0;
- } else {
- dev_info(&client->dev, "techpoint check chip id failed !\n");
+ } else if (chip_id_h == TP9951_CHIP_ID_H_VALUE &&
+ chip_id_l == TP9951_CHIP_ID_L_VALUE) { //tp2860
+ dev_info(&client->dev,
+ "techpoint check chip id CHIP_TP9951 !\n");
+ techpoint->chip_id = CHIP_TP9951;
+ techpoint->input_type = TECHPOINT_MIPI;
+ return 0;
}
+ dev_info(&client->dev, "techpoint check chip id failed !\n");
return -1;
}
@@ -138,15 +145,14 @@
if (check_chip_id(techpoint))
return -1;
- if (techpoint->chip_id == CHIP_TP9930) {
+ if (techpoint->chip_id == CHIP_TP9930)
tp9930_initialize(techpoint);
- } else if (techpoint->chip_id == CHIP_TP2855) {
+ else if (techpoint->chip_id == CHIP_TP2855)
tp2855_initialize(techpoint);
- } else if (techpoint->chip_id == CHIP_TP9950) {
+ else if (techpoint->chip_id == CHIP_TP9950)
tp9950_initialize(techpoint);
- }
-
- sema_init(®_sem, 1);
+ else if (techpoint->chip_id == CHIP_TP9951)
+ tp9951_initialize(techpoint);
return 0;
}
@@ -159,7 +165,7 @@
int need_reset_wait = -1;
if (techpoint->power_on) {
- down(®_sem);
+ mutex_lock(®_sem);
if (techpoint->chip_id == CHIP_TP9930) {
tp9930_get_all_input_status(techpoint,
techpoint->detect_status);
@@ -173,12 +179,12 @@
tp2855_set_decoder_mode(client, i,
techpoint->detect_status[i]);
}
- up(®_sem);
+ mutex_unlock(®_sem);
techpoint->do_reset = 0;
}
while (!kthread_should_stop()) {
- down(®_sem);
+ mutex_lock(®_sem);
if (techpoint->power_on) {
for (i = 0; i < PAD_MAX; i++) {
if (techpoint->chip_id == CHIP_TP9930)
@@ -188,6 +194,10 @@
else if (techpoint->chip_id == CHIP_TP2855)
detect_status =
tp2855_get_channel_input_status
+ (techpoint, i);
+ else if (techpoint->chip_id == CHIP_TP9951)
+ detect_status =
+ tp9951_get_channel_input_status
(techpoint, i);
if (techpoint->detect_status[i] !=
@@ -206,8 +216,7 @@
else if (techpoint->chip_id == CHIP_TP2855)
tp2855_set_decoder_mode(client, i, detect_status);
- techpoint->detect_status[i] =
- detect_status;
+ techpoint->detect_status[i] = detect_status;
need_reset_wait = 5;
}
}
@@ -220,7 +229,7 @@
"trigger reset time up\n");
}
}
- up(®_sem);
+ mutex_unlock(®_sem);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(200));
}
@@ -260,7 +269,7 @@
enum techpoint_support_reso reso = 0xff;
struct i2c_client *client = techpoint->client;
- down(®_sem);
+ mutex_lock(®_sem);
for (ch = 0; ch < PAD_MAX; ch++) {
if (techpoint->chip_id == CHIP_TP9930) {
@@ -277,7 +286,12 @@
tp9950_set_channel_reso(client, 0, reso);
}
- up(®_sem);
+ if (techpoint->chip_id == CHIP_TP9951) {
+ reso = tp9951_get_channel_reso(client, 0);
+ tp9951_set_channel_reso(client, 0, reso);
+ }
+
+ mutex_unlock(®_sem);
return 0;
}
@@ -290,7 +304,7 @@
enum techpoint_support_reso reso = 0xff;
struct i2c_client *client = techpoint->client;
- down(®_sem);
+ mutex_lock(®_sem);
for (ch = 0; ch < PAD_MAX; ch++) {
if (techpoint->chip_id == CHIP_TP9930) {
@@ -341,27 +355,25 @@
}
}
- up(®_sem);
+ mutex_unlock(®_sem);
}
void techpoint_get_vc_fmt_inf(struct techpoint *techpoint,
struct rkmodule_vc_fmt_info *inf)
{
- down(®_sem);
+ mutex_lock(®_sem);
- if (techpoint->chip_id == CHIP_TP9930) {
+ if (techpoint->chip_id == CHIP_TP9930)
tp9930_pll_reset(techpoint->client);
- }
techpoint_write_array(techpoint->client,
techpoint->cur_video_mode->common_reg_list,
techpoint->cur_video_mode->common_reg_size);
- if (techpoint->chip_id == CHIP_TP9930) {
+ if (techpoint->chip_id == CHIP_TP9930)
tp9930_do_reset_pll(techpoint->client);
- }
- up(®_sem);
+ mutex_unlock(®_sem);
__techpoint_get_vc_fmt_inf(techpoint, inf);
}
@@ -374,7 +386,7 @@
memset(inf, 0, sizeof(*inf));
- down(®_sem);
+ mutex_lock(®_sem);
for (ch = 0; ch < 4; ch++) {
if (techpoint->chip_id == CHIP_TP9930)
@@ -387,14 +399,13 @@
inf->detect_status |= detect_status << ch;
}
- up(®_sem);
+ mutex_unlock(®_sem);
}
void techpoint_set_quick_stream(struct techpoint *techpoint, u32 stream)
{
- if (techpoint->chip_id == CHIP_TP2855) {
+ if (techpoint->chip_id == CHIP_TP2855)
tp2855_set_quick_stream(techpoint, stream);
- }
}
int techpoint_start_video_stream(struct techpoint *techpoint)
@@ -402,11 +413,10 @@
int ret = 0;
struct i2c_client *client = techpoint->client;
- down(®_sem);
- if (techpoint->chip_id == CHIP_TP9930) {
+ mutex_lock(®_sem);
+ if (techpoint->chip_id == CHIP_TP9930)
tp9930_pll_reset(techpoint->client);
- }
- up(®_sem);
+ mutex_unlock(®_sem);
auto_detect_channel_fmt(techpoint);
ret = techpoint_write_array(techpoint->client,
@@ -414,15 +424,14 @@
techpoint->cur_video_mode->common_reg_size);
if (ret) {
dev_err(&client->dev,
- "techpoint_start_video_stream common_reg_list failed");
+ "%s common_reg_list failed", __func__);
return ret;
}
- down(®_sem);
- if (techpoint->chip_id == CHIP_TP9930) {
+ mutex_lock(®_sem);
+ if (techpoint->chip_id == CHIP_TP9930)
tp9930_do_reset_pll(techpoint->client);
- }
- up(®_sem);
+ mutex_unlock(®_sem);
usleep_range(500 * 1000, 1000 * 1000);
@@ -434,11 +443,5 @@
int techpoint_stop_video_stream(struct techpoint *techpoint)
{
detect_thread_stop(techpoint);
-
- if (techpoint->chip_id == CHIP_TP9930) {
-
- } else if (techpoint->chip_id == CHIP_TP2855) {
-
- }
return 0;
}
--
Gitblit v1.6.2