Skip to content

Commit a7fa0d0

Browse files
takaswietiwai
authored andcommitted
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>
1 parent c8de6db commit a7fa0d0

2 files changed

Lines changed: 49 additions & 48 deletions

File tree

‎sound/firewire/cmp.c‎

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414
#include "iso-resources.h"
1515
#include "cmp.h"
1616

17-
#define IMPR_SPEED_MASK 0xc0000000
18-
#define IMPR_SPEED_SHIFT 30
19-
#define IMPR_XSPEED_MASK 0x00000060
20-
#define IMPR_XSPEED_SHIFT 5
21-
#define IMPR_PLUGS_MASK 0x0000001f
22-
23-
#define IPCR_ONLINE 0x80000000
24-
#define IPCR_BCAST_CONN 0x40000000
25-
#define IPCR_P2P_CONN_MASK 0x3f000000
26-
#define IPCR_P2P_CONN_SHIFT 24
27-
#define IPCR_CHANNEL_MASK 0x003f0000
28-
#define IPCR_CHANNEL_SHIFT 16
17+
/* MPR common fields */
18+
#define MPR_SPEED_MASK 0xc0000000
19+
#define MPR_SPEED_SHIFT 30
20+
#define MPR_XSPEED_MASK 0x00000060
21+
#define MPR_XSPEED_SHIFT 5
22+
#define MPR_PLUGS_MASK 0x0000001f
23+
24+
/* PCR common fields */
25+
#define PCR_ONLINE 0x80000000
26+
#define PCR_BCAST_CONN 0x40000000
27+
#define PCR_P2P_CONN_MASK 0x3f000000
28+
#define PCR_P2P_CONN_SHIFT 24
29+
#define PCR_CHANNEL_MASK 0x003f0000
30+
#define PCR_CHANNEL_SHIFT 16
2931

3032
enum bus_reset_handling {
3133
ABORT_ON_BUS_RESET,
@@ -88,24 +90,24 @@ static int pcr_modify(struct cmp_connection *c,
8890
* cmp_connection_init - initializes a connection manager
8991
* @c: the connection manager to initialize
9092
* @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
9294
*/
9395
int cmp_connection_init(struct cmp_connection *c,
9496
struct fw_unit *unit,
95-
unsigned int ipcr_index)
97+
unsigned int pcr_index)
9698
{
97-
__be32 impr_be;
98-
u32 impr;
99+
__be32 mpr_be;
100+
u32 mpr;
99101
int err;
100102

101103
err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
102104
CSR_REGISTER_BASE + CSR_IMPR,
103-
&impr_be, 4, 0);
105+
&mpr_be, 4, 0);
104106
if (err < 0)
105107
return err;
106-
impr = be32_to_cpu(impr_be);
108+
mpr = be32_to_cpu(mpr_be);
107109

108-
if (ipcr_index >= (impr & IMPR_PLUGS_MASK))
110+
if (pcr_index >= (mpr & MPR_PLUGS_MASK))
109111
return -EINVAL;
110112

111113
err = fw_iso_resources_init(&c->resources, unit);
@@ -115,10 +117,10 @@ int cmp_connection_init(struct cmp_connection *c,
115117
c->connected = false;
116118
mutex_init(&c->mutex);
117119
c->last_pcr_value = cpu_to_be32(0x80000000);
118-
c->pcr_index = ipcr_index;
119-
c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT;
120+
c->pcr_index = pcr_index;
121+
c->max_speed = (mpr & MPR_SPEED_MASK) >> MPR_SPEED_SHIFT;
120122
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;
122124

123125
return 0;
124126
}
@@ -139,23 +141,23 @@ EXPORT_SYMBOL(cmp_connection_destroy);
139141

140142
static __be32 ipcr_set_modify(struct cmp_connection *c, __be32 ipcr)
141143
{
142-
ipcr &= ~cpu_to_be32(IPCR_BCAST_CONN |
143-
IPCR_P2P_CONN_MASK |
144-
IPCR_CHANNEL_MASK);
145-
ipcr |= cpu_to_be32(1 << IPCR_P2P_CONN_SHIFT);
146-
ipcr |= cpu_to_be32(c->resources.channel << IPCR_CHANNEL_SHIFT);
144+
ipcr &= ~cpu_to_be32(PCR_BCAST_CONN |
145+
PCR_P2P_CONN_MASK |
146+
PCR_CHANNEL_MASK);
147+
ipcr |= cpu_to_be32(1 << PCR_P2P_CONN_SHIFT);
148+
ipcr |= cpu_to_be32(c->resources.channel << PCR_CHANNEL_SHIFT);
147149

148150
return ipcr;
149151
}
150152

151-
static int ipcr_set_check(struct cmp_connection *c, __be32 ipcr)
153+
static int pcr_set_check(struct cmp_connection *c, __be32 pcr)
152154
{
153-
if (ipcr & cpu_to_be32(IPCR_BCAST_CONN |
154-
IPCR_P2P_CONN_MASK)) {
155+
if (pcr & cpu_to_be32(PCR_BCAST_CONN |
156+
PCR_P2P_CONN_MASK)) {
155157
cmp_error(c, "plug is already in use\n");
156158
return -EBUSY;
157159
}
158-
if (!(ipcr & cpu_to_be32(IPCR_ONLINE))) {
160+
if (!(pcr & cpu_to_be32(PCR_ONLINE))) {
159161
cmp_error(c, "plug is not on-line\n");
160162
return -ECONNREFUSED;
161163
}
@@ -170,9 +172,9 @@ static int ipcr_set_check(struct cmp_connection *c, __be32 ipcr)
170172
*
171173
* This function establishes a point-to-point connection from the local
172174
* computer to the target by allocating isochronous resources (channel and
173-
* bandwidth) and setting the target's input plug control register. When this
174-
* function succeeds, the caller is responsible for starting transmitting
175-
* packets.
175+
* bandwidth) and setting the target's input/output plug control register.
176+
* When this function succeeds, the caller is responsible for starting
177+
* transmitting packets.
176178
*/
177179
int cmp_connection_establish(struct cmp_connection *c,
178180
unsigned int max_payload_bytes)
@@ -193,7 +195,7 @@ int cmp_connection_establish(struct cmp_connection *c,
193195
if (err < 0)
194196
goto err_mutex;
195197

196-
err = pcr_modify(c, ipcr_set_modify, ipcr_set_check,
198+
err = pcr_modify(c, ipcr_set_modify, pcr_set_check,
197199
ABORT_ON_BUS_RESET);
198200
if (err == -EAGAIN) {
199201
fw_iso_resources_free(&c->resources);
@@ -221,8 +223,8 @@ EXPORT_SYMBOL(cmp_connection_establish);
221223
* cmp_connection_update - update the connection after a bus reset
222224
* @c: the connection manager
223225
*
224-
* This function must be called from the driver's .update handler to reestablish
225-
* any connection that might have been active.
226+
* This function must be called from the driver's .update handler to
227+
* reestablish any connection that might have been active.
226228
*
227229
* Returns zero on success, or a negative error code. On an error, the
228230
* connection is broken and the caller must stop transmitting iso packets.
@@ -242,7 +244,7 @@ int cmp_connection_update(struct cmp_connection *c)
242244
if (err < 0)
243245
goto err_unconnect;
244246

245-
err = pcr_modify(c, ipcr_set_modify, ipcr_set_check,
247+
err = pcr_modify(c, ipcr_set_modify, pcr_set_check,
246248
SUCCEED_ON_BUS_RESET);
247249
if (err < 0)
248250
goto err_resources;
@@ -261,19 +263,18 @@ int cmp_connection_update(struct cmp_connection *c)
261263
}
262264
EXPORT_SYMBOL(cmp_connection_update);
263265

264-
265-
static __be32 ipcr_break_modify(struct cmp_connection *c, __be32 ipcr)
266+
static __be32 pcr_break_modify(struct cmp_connection *c, __be32 pcr)
266267
{
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);
268269
}
269270

270271
/**
271272
* cmp_connection_break - break the connection to the target
272273
* @c: the connection manager
273274
*
274-
* This function deactives the connection in the target's input plug control
275-
* register, and frees the isochronous resources of the connection. Before
276-
* calling this function, the caller should cease transmitting packets.
275+
* This function deactives the connection in the target's input/output plug
276+
* control register, and frees the isochronous resources of the connection.
277+
* Before calling this function, the caller should cease transmitting packets.
277278
*/
278279
void cmp_connection_break(struct cmp_connection *c)
279280
{
@@ -286,7 +287,7 @@ void cmp_connection_break(struct cmp_connection *c)
286287
return;
287288
}
288289

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);
290291
if (err < 0)
291292
cmp_error(c, "plug is still connected\n");
292293

‎sound/firewire/cmp.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct fw_unit;
1111
* struct cmp_connection - manages an isochronous connection to a device
1212
* @speed: the connection's actual speed
1313
*
14-
* This structure manages (using CMP) an isochronous stream from the local
15-
* computer to a device's input plug (iPCR).
14+
* This structure manages (using CMP) an isochronous stream between the local
15+
* computer and a device's input plug (iPCR) and output plug (oPCR).
1616
*
1717
* There is no corresponding oPCR created on the local computer, so it is not
1818
* possible to overlay connections on top of this one.
@@ -30,7 +30,7 @@ struct cmp_connection {
3030

3131
int cmp_connection_init(struct cmp_connection *connection,
3232
struct fw_unit *unit,
33-
unsigned int ipcr_index);
33+
unsigned int pcr_index);
3434
void cmp_connection_destroy(struct cmp_connection *connection);
3535

3636
int cmp_connection_establish(struct cmp_connection *connection,

0 commit comments

Comments
 (0)