aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-01-22 00:17:55 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:35:11 -0500
commit8d3643637e18e6590969436734c22151805d0350 (patch)
treef6e52e9c6a2fc2de43f6ac14967e08aee2b92ce8 /drivers
parent05ad390724d1f307111a322325df83282a1479e6 (diff)
V4L/DVB (5169): Pvrusb2: Use macro names for FX2 commands
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h28
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c18
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c7
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c3
5 files changed, 47 insertions, 15 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 9e43182231a5..ee5eb26ad56d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -26,6 +26,7 @@
26#include "pvrusb2-encoder.h" 26#include "pvrusb2-encoder.h"
27#include "pvrusb2-hdw-internal.h" 27#include "pvrusb2-hdw-internal.h"
28#include "pvrusb2-debug.h" 28#include "pvrusb2-debug.h"
29#include "pvrusb2-fx2-cmd.h"
29 30
30 31
31 32
@@ -57,7 +58,7 @@ static int pvr2_encoder_write_words(struct pvr2_hdw *hdw,
57 chunkCnt = 8; 58 chunkCnt = 8;
58 if (chunkCnt > dlen) chunkCnt = dlen; 59 if (chunkCnt > dlen) chunkCnt = dlen;
59 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer)); 60 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
60 hdw->cmd_buffer[0] = 0x01; 61 hdw->cmd_buffer[0] = FX2CMD_MEM_WRITE_DWORD;
61 for (idx = 0; idx < chunkCnt; idx++) { 62 for (idx = 0; idx < chunkCnt; idx++) {
62 hdw->cmd_buffer[1+(idx*7)+6] = 0x44 + idx + offs; 63 hdw->cmd_buffer[1+(idx*7)+6] = 0x44 + idx + offs;
63 PVR2_DECOMPOSE_LE(hdw->cmd_buffer, 1+(idx*7), 64 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,
98 chunkCnt = 16; 99 chunkCnt = 16;
99 if (chunkCnt > dlen) chunkCnt = dlen; 100 if (chunkCnt > dlen) chunkCnt = dlen;
100 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer)); 101 memset(hdw->cmd_buffer,0,sizeof(hdw->cmd_buffer));
101 hdw->cmd_buffer[0] = statusFl ? 0x02 : 0x28; 102 hdw->cmd_buffer[0] =
103 (statusFl ? FX2CMD_MEM_READ_DWORD : FX2CMD_MEM_READ_64BYTES);
102 hdw->cmd_buffer[7] = 0x44 + offs; 104 hdw->cmd_buffer[7] = 0x44 + offs;
103 ret = pvr2_send_request(hdw, 105 ret = pvr2_send_request(hdw,
104 hdw->cmd_buffer,8, 106 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
index 000000000000..556628ad4ff6
--- /dev/null
+++ b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
@@ -0,0 +1,28 @@
1#ifndef _PVRUSB2_FX2_CMD_H_
2#define _PVRUSB2_FX2_CMD_H_
3
4#define FX2CMD_MEM_WRITE_DWORD 0x01
5#define FX2CMD_MEM_READ_DWORD 0x02
6
7#define FX2CMD_MEM_READ_64BYTES 0x28
8
9#define FX2CMD_REG_WRITE 0x04
10#define FX2CMD_REG_READ 0x05
11
12#define FX2CMD_I2C_WRITE 0x08
13#define FX2CMD_I2C_READ 0x09
14
15#define FX2CMD_GET_USB_SPEED 0x0b
16
17#define FX2CMD_STREAMING_ON 0x36
18#define FX2CMD_STREAMING_OFF 0x37
19
20#define FX2CMD_POWER_OFF 0xdc
21#define FX2CMD_POWER_ON 0xde
22
23#define FX2CMD_DEEP_RESET 0xdd
24
25#define FX2CMD_GET_EEPROM_ADDR 0xeb
26#define FX2CMD_GET_IR_CODE 0xec
27
28#endif /* _PVRUSB2_FX2_CMD_H_ */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 2a350755bd30..ccd871ac4b60 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -36,6 +36,7 @@
36#include "pvrusb2-hdw-internal.h" 36#include "pvrusb2-hdw-internal.h"
37#include "pvrusb2-encoder.h" 37#include "pvrusb2-encoder.h"
38#include "pvrusb2-debug.h" 38#include "pvrusb2-debug.h"
39#include "pvrusb2-fx2-cmd.h"
39 40
40#define TV_MIN_FREQ 55250000L 41#define TV_MIN_FREQ 55250000L
41#define TV_MAX_FREQ 850000000L 42#define TV_MAX_FREQ 850000000L
@@ -1647,7 +1648,7 @@ static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw)
1647 firmware needs be loaded. */ 1648 firmware needs be loaded. */
1648 int result; 1649 int result;
1649 LOCK_TAKE(hdw->ctl_lock); do { 1650 LOCK_TAKE(hdw->ctl_lock); do {
1650 hdw->cmd_buffer[0] = 0xeb; 1651 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR;
1651 result = pvr2_send_request_ex(hdw,HZ*1,!0, 1652 result = pvr2_send_request_ex(hdw,HZ*1,!0,
1652 hdw->cmd_buffer,1, 1653 hdw->cmd_buffer,1,
1653 hdw->cmd_buffer,1); 1654 hdw->cmd_buffer,1);
@@ -2526,7 +2527,7 @@ int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw)
2526{ 2527{
2527 int result; 2528 int result;
2528 LOCK_TAKE(hdw->ctl_lock); do { 2529 LOCK_TAKE(hdw->ctl_lock); do {
2529 hdw->cmd_buffer[0] = 0x0b; 2530 hdw->cmd_buffer[0] = FX2CMD_GET_USB_SPEED;
2530 result = pvr2_send_request(hdw, 2531 result = pvr2_send_request(hdw,
2531 hdw->cmd_buffer,1, 2532 hdw->cmd_buffer,1,
2532 hdw->cmd_buffer,1); 2533 hdw->cmd_buffer,1);
@@ -2976,7 +2977,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
2976 2977
2977 LOCK_TAKE(hdw->ctl_lock); 2978 LOCK_TAKE(hdw->ctl_lock);
2978 2979
2979 hdw->cmd_buffer[0] = 0x04; /* write register prefix */ 2980 hdw->cmd_buffer[0] = FX2CMD_REG_WRITE; /* write register prefix */
2980 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data); 2981 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data);
2981 hdw->cmd_buffer[5] = 0; 2982 hdw->cmd_buffer[5] = 0;
2982 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; 2983 hdw->cmd_buffer[6] = (reg >> 8) & 0xff;
@@ -2997,7 +2998,7 @@ static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2997 2998
2998 LOCK_TAKE(hdw->ctl_lock); 2999 LOCK_TAKE(hdw->ctl_lock);
2999 3000
3000 hdw->cmd_buffer[0] = 0x05; /* read register prefix */ 3001 hdw->cmd_buffer[0] = FX2CMD_REG_READ; /* read register prefix */
3001 hdw->cmd_buffer[1] = 0; 3002 hdw->cmd_buffer[1] = 0;
3002 hdw->cmd_buffer[2] = 0; 3003 hdw->cmd_buffer[2] = 0;
3003 hdw->cmd_buffer[3] = 0; 3004 hdw->cmd_buffer[3] = 0;
@@ -3121,7 +3122,7 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
3121 LOCK_TAKE(hdw->ctl_lock); do { 3122 LOCK_TAKE(hdw->ctl_lock); do {
3122 pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset"); 3123 pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
3123 hdw->flag_ok = !0; 3124 hdw->flag_ok = !0;
3124 hdw->cmd_buffer[0] = 0xdd; 3125 hdw->cmd_buffer[0] = FX2CMD_DEEP_RESET;
3125 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); 3126 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
3126 } while (0); LOCK_GIVE(hdw->ctl_lock); 3127 } while (0); LOCK_GIVE(hdw->ctl_lock);
3127 return status; 3128 return status;
@@ -3133,7 +3134,7 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
3133 int status; 3134 int status;
3134 LOCK_TAKE(hdw->ctl_lock); do { 3135 LOCK_TAKE(hdw->ctl_lock); do {
3135 pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup"); 3136 pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
3136 hdw->cmd_buffer[0] = 0xde; 3137 hdw->cmd_buffer[0] = FX2CMD_POWER_ON;
3137 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); 3138 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
3138 } while (0); LOCK_GIVE(hdw->ctl_lock); 3139 } while (0); LOCK_GIVE(hdw->ctl_lock);
3139 return status; 3140 return status;
@@ -3166,7 +3167,8 @@ static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
3166{ 3167{
3167 int status; 3168 int status;
3168 LOCK_TAKE(hdw->ctl_lock); do { 3169 LOCK_TAKE(hdw->ctl_lock); do {
3169 hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37); 3170 hdw->cmd_buffer[0] =
3171 (runFl ? FX2CMD_STREAMING_ON : FX2CMD_STREAMING_OFF);
3170 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); 3172 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
3171 } while (0); LOCK_GIVE(hdw->ctl_lock); 3173 } while (0); LOCK_GIVE(hdw->ctl_lock);
3172 if (!status) { 3174 if (!status) {
@@ -3265,7 +3267,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3265{ 3267{
3266 int result; 3268 int result;
3267 LOCK_TAKE(hdw->ctl_lock); do { 3269 LOCK_TAKE(hdw->ctl_lock); do {
3268 hdw->cmd_buffer[0] = 0xeb; 3270 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR;
3269 result = pvr2_send_request(hdw, 3271 result = pvr2_send_request(hdw,
3270 hdw->cmd_buffer,1, 3272 hdw->cmd_buffer,1,
3271 hdw->cmd_buffer,1); 3273 hdw->cmd_buffer,1);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 223a571faff3..58fc3c730fe1 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -22,6 +22,7 @@
22#include "pvrusb2-i2c-core.h" 22#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h" 23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 24#include "pvrusb2-debug.h"
25#include "pvrusb2-fx2-cmd.h"
25 26
26#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) 27#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
27 28
@@ -66,7 +67,7 @@ static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
66 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer)); 67 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
67 68
68 /* Set up command buffer for an I2C write */ 69 /* Set up command buffer for an I2C write */
69 hdw->cmd_buffer[0] = 0x08; /* write prefix */ 70 hdw->cmd_buffer[0] = FX2CMD_I2C_WRITE; /* write prefix */
70 hdw->cmd_buffer[1] = i2c_addr; /* i2c addr of chip */ 71 hdw->cmd_buffer[1] = i2c_addr; /* i2c addr of chip */
71 hdw->cmd_buffer[2] = length; /* length of what follows */ 72 hdw->cmd_buffer[2] = length; /* length of what follows */
72 if (length) memcpy(hdw->cmd_buffer + 3, data, length); 73 if (length) memcpy(hdw->cmd_buffer + 3, data, length);
@@ -128,7 +129,7 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
128 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer)); 129 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer));
129 130
130 /* Set up command buffer for an I2C write followed by a read */ 131 /* Set up command buffer for an I2C write followed by a read */
131 hdw->cmd_buffer[0] = 0x09; /* read prefix */ 132 hdw->cmd_buffer[0] = FX2CMD_I2C_READ; /* read prefix */
132 hdw->cmd_buffer[1] = dlen; /* arg length */ 133 hdw->cmd_buffer[1] = dlen; /* arg length */
133 hdw->cmd_buffer[2] = rlen; /* answer length. Device will send one 134 hdw->cmd_buffer[2] = rlen; /* answer length. Device will send one
134 more byte (status). */ 135 more byte (status). */
@@ -221,7 +222,7 @@ static int i2c_24xxx_ir(struct pvr2_hdw *hdw,
221 222
222 /* Issue a command to the FX2 to read the IR receiver. */ 223 /* Issue a command to the FX2 to read the IR receiver. */
223 LOCK_TAKE(hdw->ctl_lock); do { 224 LOCK_TAKE(hdw->ctl_lock); do {
224 hdw->cmd_buffer[0] = 0xec; 225 hdw->cmd_buffer[0] = FX2CMD_GET_IR_CODE;
225 stat = pvr2_send_request(hdw, 226 stat = pvr2_send_request(hdw,
226 hdw->cmd_buffer,1, 227 hdw->cmd_buffer,1,
227 hdw->cmd_buffer,4); 228 hdw->cmd_buffer,4);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index cde5f5f3e8f2..024b6d80ea0a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -366,8 +366,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
366 { 366 {
367 struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; 367 struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;
368 368
369 if (vt->index != 0) 369 if (vt->index != 0) break; /* Only answer for the 1st tuner */
370 break;
371 370
372 pvr2_hdw_execute_tuner_poll(hdw); 371 pvr2_hdw_execute_tuner_poll(hdw);
373 ret = pvr2_hdw_get_tuner_status(hdw,vt); 372 ret = pvr2_hdw_get_tuner_status(hdw,vt);