aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2013-01-29 06:19:30 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-08 11:17:23 -0500
commitdb8ee1064c97879bff614d653158dff1894d2e37 (patch)
treee53941839412c25e7e3189f6309c007637b4f72d /drivers/media
parent8dfef674e6c954f9b6476c1b252b385c48c9ee26 (diff)
[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: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/rc/mceusb.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 14fea35e5d67..bdd1ed8e406e 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -62,7 +62,6 @@
62#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */ 62#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */
63#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */ 63#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */
64#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */ 64#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */
65#define MCE_TX_HEADER_LENGTH 3 /* # of bytes in the initializing tx header */
66#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */ 65#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */
67#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */ 66#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */
68#define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */ 67#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 /* Formosa Industrial Computing */ 365 /* Formosa Industrial Computing */
367 { USB_DEVICE(VENDOR_FORMOSA, 0xe042) }, 366 { USB_DEVICE(VENDOR_FORMOSA, 0xe042) },
368 /* Fintek eHome Infrared Transceiver (HP branded) */ 367 /* Fintek eHome Infrared Transceiver (HP branded) */
369 { USB_DEVICE(VENDOR_FINTEK, 0x5168) }, 368 { USB_DEVICE(VENDOR_FINTEK, 0x5168),
369 .driver_info = MCE_GEN2_TX_INV },
370 /* Fintek eHome Infrared Transceiver */ 370 /* Fintek eHome Infrared Transceiver */
371 { USB_DEVICE(VENDOR_FINTEK, 0x0602) }, 371 { USB_DEVICE(VENDOR_FINTEK, 0x0602) },
372 /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */ 372 /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */
@@ -789,19 +789,19 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
789static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) 789static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
790{ 790{
791 struct mceusb_dev *ir = dev->priv; 791 struct mceusb_dev *ir = dev->priv;
792 int i, ret = 0; 792 int i, length, ret = 0;
793 int cmdcount = 0; 793 int cmdcount = 0;
794 unsigned char *cmdbuf; /* MCE command buffer */ 794 unsigned char cmdbuf[MCE_CMDBUF_SIZE];
795
796 cmdbuf = kzalloc(sizeof(unsigned) * MCE_CMDBUF_SIZE, GFP_KERNEL);
797 if (!cmdbuf)
798 return -ENOMEM;
799 795
800 /* MCE tx init header */ 796 /* MCE tx init header */
801 cmdbuf[cmdcount++] = MCE_CMD_PORT_IR; 797 cmdbuf[cmdcount++] = MCE_CMD_PORT_IR;
802 cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS; 798 cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS;
803 cmdbuf[cmdcount++] = ir->tx_mask; 799 cmdbuf[cmdcount++] = ir->tx_mask;
804 800
801 /* Send the set TX ports command */
802 mce_async_out(ir, cmdbuf, cmdcount);
803 cmdcount = 0;
804
805 /* Generate mce packet data */ 805 /* Generate mce packet data */
806 for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) { 806 for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) {
807 txbuf[i] = txbuf[i] / MCE_TIME_UNIT; 807 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 810
811 /* Insert mce packet header every 4th entry */ 811 /* Insert mce packet header every 4th entry */
812 if ((cmdcount < MCE_CMDBUF_SIZE) && 812 if ((cmdcount < MCE_CMDBUF_SIZE) &&
813 (cmdcount - MCE_TX_HEADER_LENGTH) % 813 (cmdcount % MCE_CODE_LENGTH) == 0)
814 MCE_CODE_LENGTH == 0)
815 cmdbuf[cmdcount++] = MCE_IRDATA_HEADER; 814 cmdbuf[cmdcount++] = MCE_IRDATA_HEADER;
816 815
817 /* Insert mce packet data */ 816 /* Insert mce packet data */
@@ -830,9 +829,8 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
830 } 829 }
831 830
832 /* Fix packet length in last header */ 831 /* Fix packet length in last header */
833 cmdbuf[cmdcount - (cmdcount - MCE_TX_HEADER_LENGTH) % MCE_CODE_LENGTH] = 832 length = cmdcount % MCE_CODE_LENGTH;
834 MCE_COMMAND_IRDATA + (cmdcount - MCE_TX_HEADER_LENGTH) % 833 cmdbuf[cmdcount - length] -= MCE_CODE_LENGTH - length;
835 MCE_CODE_LENGTH - 1;
836 834
837 /* Check if we have room for the empty packet at the end */ 835 /* Check if we have room for the empty packet at the end */
838 if (cmdcount >= MCE_CMDBUF_SIZE) { 836 if (cmdcount >= MCE_CMDBUF_SIZE) {
@@ -847,7 +845,6 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
847 mce_async_out(ir, cmdbuf, cmdcount); 845 mce_async_out(ir, cmdbuf, cmdcount);
848 846
849out: 847out:
850 kfree(cmdbuf);
851 return ret ? ret : count; 848 return ret ? ret : count;
852} 849}
853 850