aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-04-25 09:44:54 -0400
committerTakashi Iwai <tiwai@suse.de>2014-05-26 08:21:57 -0400
commita7fa0d047f879bf3c744e9005769183abdf2ec4b (patch)
treebcc2d44b46bd9cb04dd9041cdf23a77f79686bd8
parentc8de6dbbbb422030d3c174146b2137e69a528d69 (diff)
ALSA: firewire-lib: Rename macros, variables and functions for CMP
Referring to IEC 61883-1, oMPR and iMPR, oPCR and iPCR have some fields with the same role in the same position. This patch renames some macros, variables and function arguments with "i" in its prefix to reuse them between oMPR and iMPR, oPCR and iPCR. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/cmp.c91
-rw-r--r--sound/firewire/cmp.h6
2 files changed, 49 insertions, 48 deletions
diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c
index efdbf585e404..deb494d6e785 100644
--- a/sound/firewire/cmp.c
+++ b/sound/firewire/cmp.c
@@ -14,18 +14,20 @@
14#include "iso-resources.h" 14#include "iso-resources.h"
15#include "cmp.h" 15#include "cmp.h"
16 16
17#define IMPR_SPEED_MASK 0xc0000000 17/* MPR common fields */
18#define IMPR_SPEED_SHIFT 30 18#define MPR_SPEED_MASK 0xc0000000
19#define IMPR_XSPEED_MASK 0x00000060 19#define MPR_SPEED_SHIFT 30
20#define IMPR_XSPEED_SHIFT 5 20#define MPR_XSPEED_MASK 0x00000060
21#define IMPR_PLUGS_MASK 0x0000001f 21#define MPR_XSPEED_SHIFT 5
22 22#define MPR_PLUGS_MASK 0x0000001f
23#define IPCR_ONLINE 0x80000000 23
24#define IPCR_BCAST_CONN 0x40000000 24/* PCR common fields */
25#define IPCR_P2P_CONN_MASK 0x3f000000 25#define PCR_ONLINE 0x80000000
26#define IPCR_P2P_CONN_SHIFT 24 26#define PCR_BCAST_CONN 0x40000000
27#define IPCR_CHANNEL_MASK 0x003f0000 27#define PCR_P2P_CONN_MASK 0x3f000000
28#define IPCR_CHANNEL_SHIFT 16 28#define PCR_P2P_CONN_SHIFT 24
29#define PCR_CHANNEL_MASK 0x003f0000
30#define PCR_CHANNEL_SHIFT 16
29 31
30enum bus_reset_handling { 32enum bus_reset_handling {
31 ABORT_ON_BUS_RESET, 33 ABORT_ON_BUS_RESET,
@@ -88,24 +90,24 @@ static int pcr_modify(struct cmp_connection *c,
88 * cmp_connection_init - initializes a connection manager 90 * cmp_connection_init - initializes a connection manager
89 * @c: the connection manager to initialize 91 * @c: the connection manager to initialize
90 * @unit: a unit of the target device 92 * @unit: a unit of the target device
91 * @ipcr_index: the index of the iPCR on the target device 93 * @pcr_index: the index of the iPCR/oPCR on the target device
92 */ 94 */
93int cmp_connection_init(struct cmp_connection *c, 95int cmp_connection_init(struct cmp_connection *c,
94 struct fw_unit *unit, 96 struct fw_unit *unit,
95 unsigned int ipcr_index) 97 unsigned int pcr_index)
96{ 98{
97 __be32 impr_be; 99 __be32 mpr_be;
98 u32 impr; 100 u32 mpr;
99 int err; 101 int err;
100 102
101 err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, 103 err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
102 CSR_REGISTER_BASE + CSR_IMPR, 104 CSR_REGISTER_BASE + CSR_IMPR,
103 &impr_be, 4, 0); 105 &mpr_be, 4, 0);
104 if (err < 0) 106 if (err < 0)
105 return err; 107 return err;
106 impr = be32_to_cpu(impr_be); 108 mpr = be32_to_cpu(mpr_be);
107 109
108 if (ipcr_index >= (impr & IMPR_PLUGS_MASK)) 110 if (pcr_index >= (mpr & MPR_PLUGS_MASK))
109 return -EINVAL; 111 return -EINVAL;
110 112
111 err = fw_iso_resources_init(&c->resources, unit); 113 err = fw_iso_resources_init(&c->resources, unit);
@@ -115,10 +117,10 @@ int cmp_connection_init(struct cmp_connection *c,
115 c->connected = false; 117 c->connected = false;
116 mutex_init(&c->mutex); 118 mutex_init(&c->mutex);
117 c->last_pcr_value = cpu_to_be32(0x80000000); 119 c->last_pcr_value = cpu_to_be32(0x80000000);
118 c->pcr_index = ipcr_index; 120 c->pcr_index = pcr_index;
119 c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT; 121 c->max_speed = (mpr & MPR_SPEED_MASK) >> MPR_SPEED_SHIFT;
120 if (c->max_speed == SCODE_BETA) 122 if (c->max_speed == SCODE_BETA)
121 c->max_speed += (impr & IMPR_XSPEED_MASK) >> IMPR_XSPEED_SHIFT; 123 c->max_speed += (mpr & MPR_XSPEED_MASK) >> MPR_XSPEED_SHIFT;
122 124
123 return 0; 125 return 0;
124} 126}
@@ -139,23 +141,23 @@ EXPORT_SYMBOL(cmp_connection_destroy);
139 141
140static __be32 ipcr_set_modify(struct cmp_connection *c, __be32 ipcr) 142static __be32 ipcr_set_modify(struct cmp_connection *c, __be32 ipcr)
141{ 143{
142 ipcr &= ~cpu_to_be32(IPCR_BCAST_CONN | 144 ipcr &= ~cpu_to_be32(PCR_BCAST_CONN |
143 IPCR_P2P_CONN_MASK | 145 PCR_P2P_CONN_MASK |
144 IPCR_CHANNEL_MASK); 146 PCR_CHANNEL_MASK);
145 ipcr |= cpu_to_be32(1 << IPCR_P2P_CONN_SHIFT); 147 ipcr |= cpu_to_be32(1 << PCR_P2P_CONN_SHIFT);
146 ipcr |= cpu_to_be32(c->resources.channel << IPCR_CHANNEL_SHIFT); 148 ipcr |= cpu_to_be32(c->resources.channel << PCR_CHANNEL_SHIFT);
147 149
148 return ipcr; 150 return ipcr;
149} 151}
150 152
151static int ipcr_set_check(struct cmp_connection *c, __be32 ipcr) 153static int pcr_set_check(struct cmp_connection *c, __be32 pcr)
152{ 154{
153 if (ipcr & cpu_to_be32(IPCR_BCAST_CONN | 155 if (pcr & cpu_to_be32(PCR_BCAST_CONN |
154 IPCR_P2P_CONN_MASK)) { 156 PCR_P2P_CONN_MASK)) {
155 cmp_error(c, "plug is already in use\n"); 157 cmp_error(c, "plug is already in use\n");
156 return -EBUSY; 158 return -EBUSY;
157 } 159 }
158 if (!(ipcr & cpu_to_be32(IPCR_ONLINE))) { 160 if (!(pcr & cpu_to_be32(PCR_ONLINE))) {
159 cmp_error(c, "plug is not on-line\n"); 161 cmp_error(c, "plug is not on-line\n");
160 return -ECONNREFUSED; 162 return -ECONNREFUSED;
161 } 163 }
@@ -170,9 +172,9 @@ static int ipcr_set_check(struct cmp_connection *c, __be32 ipcr)
170 * 172 *
171 * This function establishes a point-to-point connection from the local 173 * This function establishes a point-to-point connection from the local
172 * computer to the target by allocating isochronous resources (channel and 174 * computer to the target by allocating isochronous resources (channel and
173 * bandwidth) and setting the target's input plug control register. When this 175 * bandwidth) and setting the target's input/output plug control register.
174 * function succeeds, the caller is responsible for starting transmitting 176 * When this function succeeds, the caller is responsible for starting
175 * packets. 177 * transmitting packets.
176 */ 178 */
177int cmp_connection_establish(struct cmp_connection *c, 179int cmp_connection_establish(struct cmp_connection *c,
178 unsigned int max_payload_bytes) 180 unsigned int max_payload_bytes)
@@ -193,7 +195,7 @@ retry_after_bus_reset:
193 if (err < 0) 195 if (err < 0)
194 goto err_mutex; 196 goto err_mutex;
195 197
196 err = pcr_modify(c, ipcr_set_modify, ipcr_set_check, 198 err = pcr_modify(c, ipcr_set_modify, pcr_set_check,
197 ABORT_ON_BUS_RESET); 199 ABORT_ON_BUS_RESET);
198 if (err == -EAGAIN) { 200 if (err == -EAGAIN) {
199 fw_iso_resources_free(&c->resources); 201 fw_iso_resources_free(&c->resources);
@@ -221,8 +223,8 @@ EXPORT_SYMBOL(cmp_connection_establish);
221 * cmp_connection_update - update the connection after a bus reset 223 * cmp_connection_update - update the connection after a bus reset
222 * @c: the connection manager 224 * @c: the connection manager
223 * 225 *
224 * This function must be called from the driver's .update handler to reestablish 226 * This function must be called from the driver's .update handler to
225 * any connection that might have been active. 227 * reestablish any connection that might have been active.
226 * 228 *
227 * Returns zero on success, or a negative error code. On an error, the 229 * Returns zero on success, or a negative error code. On an error, the
228 * connection is broken and the caller must stop transmitting iso packets. 230 * connection is broken and the caller must stop transmitting iso packets.
@@ -242,7 +244,7 @@ int cmp_connection_update(struct cmp_connection *c)
242 if (err < 0) 244 if (err < 0)
243 goto err_unconnect; 245 goto err_unconnect;
244 246
245 err = pcr_modify(c, ipcr_set_modify, ipcr_set_check, 247 err = pcr_modify(c, ipcr_set_modify, pcr_set_check,
246 SUCCEED_ON_BUS_RESET); 248 SUCCEED_ON_BUS_RESET);
247 if (err < 0) 249 if (err < 0)
248 goto err_resources; 250 goto err_resources;
@@ -261,19 +263,18 @@ err_unconnect:
261} 263}
262EXPORT_SYMBOL(cmp_connection_update); 264EXPORT_SYMBOL(cmp_connection_update);
263 265
264 266static __be32 pcr_break_modify(struct cmp_connection *c, __be32 pcr)
265static __be32 ipcr_break_modify(struct cmp_connection *c, __be32 ipcr)
266{ 267{
267 return ipcr & ~cpu_to_be32(IPCR_BCAST_CONN | IPCR_P2P_CONN_MASK); 268 return pcr & ~cpu_to_be32(PCR_BCAST_CONN | PCR_P2P_CONN_MASK);
268} 269}
269 270
270/** 271/**
271 * cmp_connection_break - break the connection to the target 272 * cmp_connection_break - break the connection to the target
272 * @c: the connection manager 273 * @c: the connection manager
273 * 274 *
274 * This function deactives the connection in the target's input plug control 275 * This function deactives the connection in the target's input/output plug
275 * register, and frees the isochronous resources of the connection. Before 276 * control register, and frees the isochronous resources of the connection.
276 * calling this function, the caller should cease transmitting packets. 277 * Before calling this function, the caller should cease transmitting packets.
277 */ 278 */
278void cmp_connection_break(struct cmp_connection *c) 279void cmp_connection_break(struct cmp_connection *c)
279{ 280{
@@ -286,7 +287,7 @@ void cmp_connection_break(struct cmp_connection *c)
286 return; 287 return;
287 } 288 }
288 289
289 err = pcr_modify(c, ipcr_break_modify, NULL, SUCCEED_ON_BUS_RESET); 290 err = pcr_modify(c, pcr_break_modify, NULL, SUCCEED_ON_BUS_RESET);
290 if (err < 0) 291 if (err < 0)
291 cmp_error(c, "plug is still connected\n"); 292 cmp_error(c, "plug is still connected\n");
292 293
diff --git a/sound/firewire/cmp.h b/sound/firewire/cmp.h
index f47de08feb12..2320cd44d499 100644
--- a/sound/firewire/cmp.h
+++ b/sound/firewire/cmp.h
@@ -11,8 +11,8 @@ struct fw_unit;
11 * struct cmp_connection - manages an isochronous connection to a device 11 * struct cmp_connection - manages an isochronous connection to a device
12 * @speed: the connection's actual speed 12 * @speed: the connection's actual speed
13 * 13 *
14 * This structure manages (using CMP) an isochronous stream from the local 14 * This structure manages (using CMP) an isochronous stream between the local
15 * computer to a device's input plug (iPCR). 15 * computer and a device's input plug (iPCR) and output plug (oPCR).
16 * 16 *
17 * There is no corresponding oPCR created on the local computer, so it is not 17 * There is no corresponding oPCR created on the local computer, so it is not
18 * possible to overlay connections on top of this one. 18 * possible to overlay connections on top of this one.
@@ -30,7 +30,7 @@ struct cmp_connection {
30 30
31int cmp_connection_init(struct cmp_connection *connection, 31int cmp_connection_init(struct cmp_connection *connection,
32 struct fw_unit *unit, 32 struct fw_unit *unit,
33 unsigned int ipcr_index); 33 unsigned int pcr_index);
34void cmp_connection_destroy(struct cmp_connection *connection); 34void cmp_connection_destroy(struct cmp_connection *connection);
35 35
36int cmp_connection_establish(struct cmp_connection *connection, 36int cmp_connection_establish(struct cmp_connection *connection,