V4L/DVB (5169): Pvrusb2: Use macro names for FX2 commands
authorMichael Krufky <mkrufky@linuxtv.org>
Mon, 22 Jan 2007 05:17:55 +0000 (02:17 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 21 Feb 2007 15:35:11 +0000 (13:35 -0200)
This is a maintainability cleanup; use nice names for all the FX2
commands instead of raw bytes.  This way we can easily find where we
issue FX commands.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/pvrusb2/pvrusb2-encoder.c
drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h [new file with mode: 0644]
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c

index 9e43182231a5bc2ed7688ab47ecb7122c3b4aa58..ee5eb26ad56d0477ef7cc4bd2f6576d726afa021 100644 (file)
@@ -26,6 +26,7 @@
 #include "pvrusb2-encoder.h"
 #include "pvrusb2-hdw-internal.h"
 #include "pvrusb2-debug.h"
+#include "pvrusb2-fx2-cmd.h"
 
 
 
@@ -57,7 +58,7 @@ static int pvr2_encoder_write_words(struct pvr2_hdw *hdw,
                chunkCnt = 8;
                if (chunkCnt > dlen) chunkCnt = dlen;
                memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
-               hdw->cmd_buffer[0] = 0x01;
+               hdw->cmd_buffer[0] = FX2CMD_MEM_WRITE_DWORD;
                for (idx = 0; idx < chunkCnt; idx++) {
                        hdw->cmd_buffer[1+(idx*7)+6] = 0x44 + idx + offs;
                        PVR2_DECOMPOSE_LE(hdw->cmd_buffer, 1+(idx*7),
@@ -98,7 +99,8 @@ static int pvr2_encoder_read_words(struct pvr2_hdw *hdw,int statusFl,
                chunkCnt = 16;
                if (chunkCnt > dlen) chunkCnt = dlen;
                memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
-               hdw->cmd_buffer[0] = statusFl ? 0x02 : 0x28;
+               hdw->cmd_buffer[0] =
+                       (statusFl ? FX2CMD_MEM_READ_DWORD : FX2CMD_MEM_READ_64BYTES);
                hdw->cmd_buffer[7] = 0x44 + offs;
                ret = pvr2_send_request(hdw,
                                        hdw->cmd_buffer,8,
diff --git a/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
new file mode 100644 (file)
index 0000000..556628a
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _PVRUSB2_FX2_CMD_H_
+#define _PVRUSB2_FX2_CMD_H_
+
+#define FX2CMD_MEM_WRITE_DWORD  0x01
+#define FX2CMD_MEM_READ_DWORD   0x02
+
+#define FX2CMD_MEM_READ_64BYTES 0x28
+
+#define FX2CMD_REG_WRITE        0x04
+#define FX2CMD_REG_READ         0x05
+
+#define FX2CMD_I2C_WRITE        0x08
+#define FX2CMD_I2C_READ         0x09
+
+#define FX2CMD_GET_USB_SPEED    0x0b
+
+#define FX2CMD_STREAMING_ON     0x36
+#define FX2CMD_STREAMING_OFF    0x37
+
+#define FX2CMD_POWER_OFF        0xdc
+#define FX2CMD_POWER_ON         0xde
+
+#define FX2CMD_DEEP_RESET       0xdd
+
+#define FX2CMD_GET_EEPROM_ADDR  0xeb
+#define FX2CMD_GET_IR_CODE      0xec
+
+#endif /* _PVRUSB2_FX2_CMD_H_ */
index 2a350755bd30d58e7979a6806110225dfeeca071..ccd871ac4b60a2c0051a34f7254fab715ad668f3 100644 (file)
@@ -36,6 +36,7 @@
 #include "pvrusb2-hdw-internal.h"
 #include "pvrusb2-encoder.h"
 #include "pvrusb2-debug.h"
+#include "pvrusb2-fx2-cmd.h"
 
 #define TV_MIN_FREQ     55250000L
 #define TV_MAX_FREQ    850000000L
@@ -1647,7 +1648,7 @@ static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw)
           firmware needs be loaded. */
        int result;
        LOCK_TAKE(hdw->ctl_lock); do {
-               hdw->cmd_buffer[0] = 0xeb;
+               hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR;
                result = pvr2_send_request_ex(hdw,HZ*1,!0,
                                           hdw->cmd_buffer,1,
                                           hdw->cmd_buffer,1);
@@ -2526,7 +2527,7 @@ int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw)
 {
        int result;
        LOCK_TAKE(hdw->ctl_lock); do {
-               hdw->cmd_buffer[0] = 0x0b;
+               hdw->cmd_buffer[0] = FX2CMD_GET_USB_SPEED;
                result = pvr2_send_request(hdw,
                                           hdw->cmd_buffer,1,
                                           hdw->cmd_buffer,1);
@@ -2976,7 +2977,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
 
        LOCK_TAKE(hdw->ctl_lock);
 
-       hdw->cmd_buffer[0] = 0x04;  /* write register prefix */
+       hdw->cmd_buffer[0] = FX2CMD_REG_WRITE;  /* write register prefix */
        PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data);
        hdw->cmd_buffer[5] = 0;
        hdw->cmd_buffer[6] = (reg >> 8) & 0xff;
@@ -2997,7 +2998,7 @@ static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
 
        LOCK_TAKE(hdw->ctl_lock);
 
-       hdw->cmd_buffer[0] = 0x05;  /* read register prefix */
+       hdw->cmd_buffer[0] = FX2CMD_REG_READ;  /* read register prefix */
        hdw->cmd_buffer[1] = 0;
        hdw->cmd_buffer[2] = 0;
        hdw->cmd_buffer[3] = 0;
@@ -3121,7 +3122,7 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
        LOCK_TAKE(hdw->ctl_lock); do {
                pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
                hdw->flag_ok = !0;
-               hdw->cmd_buffer[0] = 0xdd;
+               hdw->cmd_buffer[0] = FX2CMD_DEEP_RESET;
                status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
@@ -3133,7 +3134,7 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
        int status;
        LOCK_TAKE(hdw->ctl_lock); do {
                pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
-               hdw->cmd_buffer[0] = 0xde;
+               hdw->cmd_buffer[0] = FX2CMD_POWER_ON;
                status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
@@ -3166,7 +3167,8 @@ static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
 {
        int status;
        LOCK_TAKE(hdw->ctl_lock); do {
-               hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37);
+               hdw->cmd_buffer[0] =
+                       (runFl ? FX2CMD_STREAMING_ON : FX2CMD_STREAMING_OFF);
                status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        if (!status) {
@@ -3265,7 +3267,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
 {
        int result;
        LOCK_TAKE(hdw->ctl_lock); do {
-               hdw->cmd_buffer[0] = 0xeb;
+               hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR;
                result = pvr2_send_request(hdw,
                                           hdw->cmd_buffer,1,
                                           hdw->cmd_buffer,1);
index 223a571faff3658bcba3d44910f75580cc8ed2f8..58fc3c730fe189bb5f608f42a04a9316fd10be41 100644 (file)
@@ -22,6 +22,7 @@
 #include "pvrusb2-i2c-core.h"
 #include "pvrusb2-hdw-internal.h"
 #include "pvrusb2-debug.h"
+#include "pvrusb2-fx2-cmd.h"
 
 #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
 
@@ -66,7 +67,7 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
        memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
 
        /* Set up command buffer for an I2C write */
-       hdw->cmd_buffer[0] = 0x08;      /* write prefix */
+       hdw->cmd_buffer[0] = FX2CMD_I2C_WRITE;      /* write prefix */
        hdw->cmd_buffer[1] = i2c_addr;  /* i2c addr of chip */
        hdw->cmd_buffer[2] = length;    /* length of what follows */
        if (length) memcpy(hdw->cmd_buffer + 3, data, length);
@@ -128,7 +129,7 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
        memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
 
        /* Set up command buffer for an I2C write followed by a read */
-       hdw->cmd_buffer[0] = 0x09;  /* read prefix */
+       hdw->cmd_buffer[0] = FX2CMD_I2C_READ;  /* read prefix */
        hdw->cmd_buffer[1] = dlen;  /* arg length */
        hdw->cmd_buffer[2] = rlen;  /* answer length. Device will send one
                                       more byte (status). */
@@ -221,7 +222,7 @@ static int i2c_24xxx_ir(struct pvr2_hdw *hdw,
 
        /* Issue a command to the FX2 to read the IR receiver. */
        LOCK_TAKE(hdw->ctl_lock); do {
-               hdw->cmd_buffer[0] = 0xec;
+               hdw->cmd_buffer[0] = FX2CMD_GET_IR_CODE;
                stat = pvr2_send_request(hdw,
                                         hdw->cmd_buffer,1,
                                         hdw->cmd_buffer,4);
index cde5f5f3e8f2dab131a3e9454647d32ef02ac6af..024b6d80ea0acc438a2a3b88f6155d7aa6371123 100644 (file)
@@ -366,8 +366,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
        {
                struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;
 
-               if (vt->index != 0)
-                       break;
+               if (vt->index != 0) break; /* Only answer for the 1st tuner */
 
                pvr2_hdw_execute_tuner_poll(hdw);
                ret = pvr2_hdw_get_tuner_status(hdw,vt);