Skip to content

Commit 8728427

Browse files
hkallweitmchehab
authored andcommitted
media: rc: nuvoton: remove rudimentary transmit functionality
Transmit support in this driver was never tested and based on the code it can't work. Just one example: The buffer provided to nvt_tx_ir holds unsigned int values in micro seconds: First value is for a pulse, second for a pause, etc. Bytes in this buffer are copied as-is to the chip FIFO what can't work as the chip-internal format is totally different. See also conversion done in nvt_process_rx_ir_data. Even if we would try to fix this we have the issue that we can't test it. There seems to be no device on the market using IR transmit with one of the chips supported by this driver. To facilitate maintenance of the driver I'd propose to remove the rudimentary transmit support. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Sean Young <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent a8c2d62 commit 8728427

File tree

2 files changed

+3
-135
lines changed

2 files changed

+3
-135
lines changed

drivers/media/rc/nuvoton-cir.c

Lines changed: 3 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -727,70 +727,6 @@ static int nvt_ir_raw_set_wakeup_filter(struct rc_dev *dev,
727727
return ret;
728728
}
729729

730-
/*
731-
* nvt_tx_ir
732-
*
733-
* 1) clean TX fifo first (handled by AP)
734-
* 2) copy data from user space
735-
* 3) disable RX interrupts, enable TX interrupts: TTR & TFU
736-
* 4) send 9 packets to TX FIFO to open TTR
737-
* in interrupt_handler:
738-
* 5) send all data out
739-
* go back to write():
740-
* 6) disable TX interrupts, re-enable RX interupts
741-
*
742-
* The key problem of this function is user space data may larger than
743-
* driver's data buf length. So nvt_tx_ir() will only copy TX_BUF_LEN data to
744-
* buf, and keep current copied data buf num in cur_buf_num. But driver's buf
745-
* number may larger than TXFCONT (0xff). So in interrupt_handler, it has to
746-
* set TXFCONT as 0xff, until buf_count less than 0xff.
747-
*/
748-
static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
749-
{
750-
struct nvt_dev *nvt = dev->priv;
751-
unsigned long flags;
752-
unsigned int i;
753-
u8 iren;
754-
int ret;
755-
756-
spin_lock_irqsave(&nvt->lock, flags);
757-
758-
ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n);
759-
nvt->tx.buf_count = (ret * sizeof(unsigned));
760-
761-
memcpy(nvt->tx.buf, txbuf, nvt->tx.buf_count);
762-
763-
nvt->tx.cur_buf_num = 0;
764-
765-
/* save currently enabled interrupts */
766-
iren = nvt_cir_reg_read(nvt, CIR_IREN);
767-
768-
/* now disable all interrupts, save TFU & TTR */
769-
nvt_cir_reg_write(nvt, CIR_IREN_TFU | CIR_IREN_TTR, CIR_IREN);
770-
771-
nvt->tx.tx_state = ST_TX_REPLY;
772-
773-
nvt_cir_reg_write(nvt, CIR_FIFOCON_TX_TRIGGER_LEV_8 |
774-
CIR_FIFOCON_RXFIFOCLR, CIR_FIFOCON);
775-
776-
/* trigger TTR interrupt by writing out ones, (yes, it's ugly) */
777-
for (i = 0; i < 9; i++)
778-
nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO);
779-
780-
spin_unlock_irqrestore(&nvt->lock, flags);
781-
782-
wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST);
783-
784-
spin_lock_irqsave(&nvt->lock, flags);
785-
nvt->tx.tx_state = ST_TX_NONE;
786-
spin_unlock_irqrestore(&nvt->lock, flags);
787-
788-
/* restore enabled interrupts to prior state */
789-
nvt_cir_reg_write(nvt, iren, CIR_IREN);
790-
791-
return ret;
792-
}
793-
794730
/* dump contents of the last rx buffer we got from the hw rx fifo */
795731
static void nvt_dump_rx_buf(struct nvt_dev *nvt)
796732
{
@@ -895,11 +831,6 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
895831
CIR_IRSTS_TFU | CIR_IRSTS_GH) ? " ?" : "");
896832
}
897833

898-
static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
899-
{
900-
return nvt->tx.tx_state == ST_TX_NONE;
901-
}
902-
903834
/* interrupt service routine for incoming and outgoing CIR data */
904835
static irqreturn_t nvt_cir_isr(int irq, void *data)
905836
{
@@ -952,40 +883,8 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
952883

953884
if (status & CIR_IRSTS_RFO)
954885
nvt_handle_rx_fifo_overrun(nvt);
955-
956-
else if (status & (CIR_IRSTS_RTR | CIR_IRSTS_PE)) {
957-
/* We only do rx if not tx'ing */
958-
if (nvt_cir_tx_inactive(nvt))
959-
nvt_get_rx_ir_data(nvt);
960-
}
961-
962-
if (status & CIR_IRSTS_TE)
963-
nvt_clear_tx_fifo(nvt);
964-
965-
if (status & CIR_IRSTS_TTR) {
966-
unsigned int pos, count;
967-
u8 tmp;
968-
969-
pos = nvt->tx.cur_buf_num;
970-
count = nvt->tx.buf_count;
971-
972-
/* Write data into the hardware tx fifo while pos < count */
973-
if (pos < count) {
974-
nvt_cir_reg_write(nvt, nvt->tx.buf[pos], CIR_STXFIFO);
975-
nvt->tx.cur_buf_num++;
976-
/* Disable TX FIFO Trigger Level Reach (TTR) interrupt */
977-
} else {
978-
tmp = nvt_cir_reg_read(nvt, CIR_IREN);
979-
nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN);
980-
}
981-
}
982-
983-
if (status & CIR_IRSTS_TFU) {
984-
if (nvt->tx.tx_state == ST_TX_REPLY) {
985-
nvt->tx.tx_state = ST_TX_REQUEST;
986-
wake_up(&nvt->tx.queue);
987-
}
988-
}
886+
else if (status & (CIR_IRSTS_RTR | CIR_IRSTS_PE))
887+
nvt_get_rx_ir_data(nvt);
989888

990889
spin_unlock(&nvt->lock);
991890

@@ -1062,7 +961,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1062961
if (!nvt)
1063962
return -ENOMEM;
1064963

1065-
/* input device for IR remote (and tx) */
964+
/* input device for IR remote */
1066965
nvt->rdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW);
1067966
if (!nvt->rdev)
1068967
return -ENOMEM;
@@ -1105,8 +1004,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
11051004

11061005
pnp_set_drvdata(pdev, nvt);
11071006

1108-
init_waitqueue_head(&nvt->tx.queue);
1109-
11101007
ret = nvt_hw_detect(nvt);
11111008
if (ret)
11121009
return ret;
@@ -1131,7 +1028,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
11311028
rdev->encode_wakeup = true;
11321029
rdev->open = nvt_open;
11331030
rdev->close = nvt_close;
1134-
rdev->tx_ir = nvt_tx_ir;
11351031
rdev->s_tx_carrier = nvt_set_tx_carrier;
11361032
rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter;
11371033
rdev->device_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
@@ -1148,8 +1044,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
11481044
#if 0
11491045
rdev->min_timeout = XYZ;
11501046
rdev->max_timeout = XYZ;
1151-
/* tx bits */
1152-
rdev->tx_resolution = XYZ;
11531047
#endif
11541048
ret = devm_rc_register_device(&pdev->dev, rdev);
11551049
if (ret)
@@ -1205,8 +1099,6 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
12051099

12061100
spin_lock_irqsave(&nvt->lock, flags);
12071101

1208-
nvt->tx.tx_state = ST_TX_NONE;
1209-
12101102
/* disable all CIR interrupts */
12111103
nvt_cir_reg_write(nvt, 0, CIR_IREN);
12121104

drivers/media/rc/nuvoton-cir.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ static int debug;
4646
KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__)
4747

4848

49-
/*
50-
* Original lirc driver said min value of 76, and recommended value of 256
51-
* for the buffer length, but then used 2048. Never mind that the size of the
52-
* RX FIFO is 32 bytes... So I'm using 32 for RX and 256 for TX atm, but I'm
53-
* not sure if maybe that TX value is off by a factor of 8 (bits vs. bytes),
54-
* and I don't have TX-capable hardware to test/debug on...
55-
*/
56-
#define TX_BUF_LEN 256
5749
#define RX_BUF_LEN 32
5850

5951
#define SIO_ID_MASK 0xfff0
@@ -81,14 +73,6 @@ struct nvt_dev {
8173
u8 buf[RX_BUF_LEN];
8274
unsigned int pkts;
8375

84-
struct {
85-
u8 buf[TX_BUF_LEN];
86-
unsigned int buf_count;
87-
unsigned int cur_buf_num;
88-
wait_queue_head_t queue;
89-
u8 tx_state;
90-
} tx;
91-
9276
/* EFER Config register index/data pair */
9377
u32 cr_efir;
9478
u32 cr_efdr;
@@ -103,18 +87,10 @@ struct nvt_dev {
10387
u8 chip_major;
10488
u8 chip_minor;
10589

106-
/* hardware features */
107-
bool hw_tx_capable;
108-
10990
/* carrier period = 1 / frequency */
11091
u32 carrier;
11192
};
11293

113-
/* send states */
114-
#define ST_TX_NONE 0x0
115-
#define ST_TX_REQUEST 0x2
116-
#define ST_TX_REPLY 0x4
117-
11894
/* buffer packet constants */
11995
#define BUF_PULSE_BIT 0x80
12096
#define BUF_LEN_MASK 0x7f

0 commit comments

Comments
 (0)