2 * oxfw_command.c - a part of driver for OXFW970/971 based devices
4 * Copyright (c) 2014 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
11 int avc_stream_set_format(struct fw_unit
*unit
, enum avc_general_plug_dir dir
,
12 unsigned int pid
, u8
*format
, unsigned int len
)
17 buf
= kmalloc(len
+ 10, GFP_KERNEL
);
21 buf
[0] = 0x00; /* CONTROL */
22 buf
[1] = 0xff; /* UNIT */
23 buf
[2] = 0xbf; /* EXTENDED STREAM FORMAT INFORMATION */
24 buf
[3] = 0xc0; /* SINGLE subfunction */
25 buf
[4] = dir
; /* Plug Direction */
26 buf
[5] = 0x00; /* UNIT */
27 buf
[6] = 0x00; /* PCR (Isochronous Plug) */
28 buf
[7] = 0xff & pid
; /* Plug ID */
29 buf
[8] = 0xff; /* Padding */
30 buf
[9] = 0xff; /* Support status in response */
31 memcpy(buf
+ 10, format
, len
);
33 /* do transaction and check buf[1-8] are the same against command */
34 err
= fcp_avc_transaction(unit
, buf
, len
+ 10, buf
, len
+ 10,
35 BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
36 BIT(6) | BIT(7) | BIT(8));
37 if ((err
> 0) && (err
< len
+ 10))
39 else if (buf
[0] == 0x08) /* NOT IMPLEMENTED */
41 else if (buf
[0] == 0x0a) /* REJECTED */
51 int avc_stream_get_format(struct fw_unit
*unit
,
52 enum avc_general_plug_dir dir
, unsigned int pid
,
53 u8
*buf
, unsigned int *len
, unsigned int eid
)
59 subfunc
= 0xc0; /* SINGLE */
61 subfunc
= 0xc1; /* LIST */
63 buf
[0] = 0x01; /* STATUS */
64 buf
[1] = 0xff; /* UNIT */
65 buf
[2] = 0xbf; /* EXTENDED STREAM FORMAT INFORMATION */
66 buf
[3] = subfunc
; /* SINGLE or LIST */
67 buf
[4] = dir
; /* Plug Direction */
68 buf
[5] = 0x00; /* Unit */
69 buf
[6] = 0x00; /* PCR (Isochronous Plug) */
70 buf
[7] = 0xff & pid
; /* Plug ID */
71 buf
[8] = 0xff; /* Padding */
72 buf
[9] = 0xff; /* support status in response */
73 buf
[10] = 0xff & eid
; /* entry ID for LIST subfunction */
74 buf
[11] = 0xff; /* padding */
76 /* do transaction and check buf[1-7] are the same against command */
77 err
= fcp_avc_transaction(unit
, buf
, 12, buf
, *len
,
78 BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
80 if ((err
> 0) && (err
< 10))
82 else if (buf
[0] == 0x08) /* NOT IMPLEMENTED */
84 else if (buf
[0] == 0x0a) /* REJECTED */
86 else if (buf
[0] == 0x0b) /* IN TRANSITION */
88 /* LIST subfunction has entry ID */
89 else if ((subfunc
== 0xc1) && (buf
[10] != eid
))
94 /* keep just stream format information */
95 if (subfunc
== 0xc0) {
96 memmove(buf
, buf
+ 10, err
- 10);
99 memmove(buf
, buf
+ 11, err
- 11);
108 int avc_general_inquiry_sig_fmt(struct fw_unit
*unit
, unsigned int rate
,
109 enum avc_general_plug_dir dir
,
116 for (sfc
= 0; sfc
< CIP_SFC_COUNT
; sfc
++) {
117 if (amdtp_rate_table
[sfc
] == rate
)
120 if (sfc
== CIP_SFC_COUNT
)
123 buf
= kzalloc(8, GFP_KERNEL
);
127 buf
[0] = 0x02; /* SPECIFIC INQUIRY */
128 buf
[1] = 0xff; /* UNIT */
129 if (dir
== AVC_GENERAL_PLUG_DIR_IN
)
130 buf
[2] = 0x19; /* INPUT PLUG SIGNAL FORMAT */
132 buf
[2] = 0x18; /* OUTPUT PLUG SIGNAL FORMAT */
133 buf
[3] = 0xff & pid
; /* plug id */
134 buf
[4] = 0x90; /* EOH_1, Form_1, FMT. AM824 */
135 buf
[5] = 0x07 & sfc
; /* FDF-hi. AM824, frequency */
136 buf
[6] = 0xff; /* FDF-mid. AM824, SYT hi (not used) */
137 buf
[7] = 0xff; /* FDF-low. AM824, SYT lo (not used) */
139 /* do transaction and check buf[1-5] are the same against command */
140 err
= fcp_avc_transaction(unit
, buf
, 8, buf
, 8,
141 BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5));
142 if ((err
> 0) && (err
< 8))
144 else if (buf
[0] == 0x08) /* NOT IMPLEMENTED */