Commit db8ee106 authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

[media] mceusb: make transmit work on HP transceiver

This transceiver expects the set IR TX ports and IR data as seperate
packets, like the Windows driver does. Remove unnecessary kzalloc.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8dfef674
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */ #define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */
#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */ #define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */
#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */ #define MCE_IRDATA_TRAILER 0x80 /* End of IR data */
#define MCE_TX_HEADER_LENGTH 3 /* # of bytes in the initializing tx header */
#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */ #define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */
#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */ #define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */
#define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */ #define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */
...@@ -366,7 +365,8 @@ static struct usb_device_id mceusb_dev_table[] = { ...@@ -366,7 +365,8 @@ static struct usb_device_id mceusb_dev_table[] = {
/* Formosa Industrial Computing */ /* Formosa Industrial Computing */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe042) }, { USB_DEVICE(VENDOR_FORMOSA, 0xe042) },
/* Fintek eHome Infrared Transceiver (HP branded) */ /* Fintek eHome Infrared Transceiver (HP branded) */
{ USB_DEVICE(VENDOR_FINTEK, 0x5168) }, { USB_DEVICE(VENDOR_FINTEK, 0x5168),
.driver_info = MCE_GEN2_TX_INV },
/* Fintek eHome Infrared Transceiver */ /* Fintek eHome Infrared Transceiver */
{ USB_DEVICE(VENDOR_FINTEK, 0x0602) }, { USB_DEVICE(VENDOR_FINTEK, 0x0602) },
/* Fintek eHome Infrared Transceiver (in the AOpen MP45) */ /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */
...@@ -789,19 +789,19 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size) ...@@ -789,19 +789,19 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
{ {
struct mceusb_dev *ir = dev->priv; struct mceusb_dev *ir = dev->priv;
int i, ret = 0; int i, length, ret = 0;
int cmdcount = 0; int cmdcount = 0;
unsigned char *cmdbuf; /* MCE command buffer */ unsigned char cmdbuf[MCE_CMDBUF_SIZE];
cmdbuf = kzalloc(sizeof(unsigned) * MCE_CMDBUF_SIZE, GFP_KERNEL);
if (!cmdbuf)
return -ENOMEM;
/* MCE tx init header */ /* MCE tx init header */
cmdbuf[cmdcount++] = MCE_CMD_PORT_IR; cmdbuf[cmdcount++] = MCE_CMD_PORT_IR;
cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS; cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS;
cmdbuf[cmdcount++] = ir->tx_mask; cmdbuf[cmdcount++] = ir->tx_mask;
/* Send the set TX ports command */
mce_async_out(ir, cmdbuf, cmdcount);
cmdcount = 0;
/* Generate mce packet data */ /* Generate mce packet data */
for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) { for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) {
txbuf[i] = txbuf[i] / MCE_TIME_UNIT; txbuf[i] = txbuf[i] / MCE_TIME_UNIT;
...@@ -810,8 +810,7 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) ...@@ -810,8 +810,7 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
/* Insert mce packet header every 4th entry */ /* Insert mce packet header every 4th entry */
if ((cmdcount < MCE_CMDBUF_SIZE) && if ((cmdcount < MCE_CMDBUF_SIZE) &&
(cmdcount - MCE_TX_HEADER_LENGTH) % (cmdcount % MCE_CODE_LENGTH) == 0)
MCE_CODE_LENGTH == 0)
cmdbuf[cmdcount++] = MCE_IRDATA_HEADER; cmdbuf[cmdcount++] = MCE_IRDATA_HEADER;
/* Insert mce packet data */ /* Insert mce packet data */
...@@ -830,9 +829,8 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) ...@@ -830,9 +829,8 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
} }
/* Fix packet length in last header */ /* Fix packet length in last header */
cmdbuf[cmdcount - (cmdcount - MCE_TX_HEADER_LENGTH) % MCE_CODE_LENGTH] = length = cmdcount % MCE_CODE_LENGTH;
MCE_COMMAND_IRDATA + (cmdcount - MCE_TX_HEADER_LENGTH) % cmdbuf[cmdcount - length] -= MCE_CODE_LENGTH - length;
MCE_CODE_LENGTH - 1;
/* Check if we have room for the empty packet at the end */ /* Check if we have room for the empty packet at the end */
if (cmdcount >= MCE_CMDBUF_SIZE) { if (cmdcount >= MCE_CMDBUF_SIZE) {
...@@ -847,7 +845,6 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) ...@@ -847,7 +845,6 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
mce_async_out(ir, cmdbuf, cmdcount); mce_async_out(ir, cmdbuf, cmdcount);
out: out:
kfree(cmdbuf);
return ret ? ret : count; return ret ? ret : count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment