182 | | } |
---|
| 184 | signed int Device::read_tco(quadlet_t *tco_data, signed int size) |
---|
| 185 | { |
---|
| 186 | // Read the TCO registers and return the respective values in *tco_data. |
---|
| 187 | // Return value is 0 on success, or -1 if there is no TCO present. |
---|
| 188 | // "size" is the size (in quadlets) of the array pointed to by tco_data. |
---|
| 189 | // To obtain all TCO data "size" should be at least 4. If the caller |
---|
| 190 | // doesn't care about the data returned by the TCO, tco_data can be |
---|
| 191 | // NULL. |
---|
| 192 | quadlet_t buf[4]; |
---|
| 193 | signed int i; |
---|
| 194 | |
---|
| 195 | // The Fireface 400 can't have the TCO fitted |
---|
| 196 | if (m_rme_model==RME_MODEL_FIREFACE400) |
---|
| 197 | return -1; |
---|
| 198 | |
---|
| 199 | if (readBlock(RME_FF_TCO_READ_REG, buf, 4) != 0) |
---|
| 200 | return -1; |
---|
| 201 | |
---|
| 202 | if (tco_data != NULL) { |
---|
| 203 | for (i=0; i<(size<4)?size:4; i++) |
---|
| 204 | tco_data[i] = buf[i]; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | if ( (buf[0] & 0x80808080) == 0x80808080 && |
---|
| 208 | (buf[1] & 0x80808080) == 0x80808080 && |
---|
| 209 | (buf[2] & 0x80808080) == 0x80808080 && |
---|
| 210 | (buf[3] & 0x8000FFFF) == 0x80008000) { |
---|
| 211 | // A TCO is present |
---|
| 212 | return 0; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | return -1; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | signed int Device::write_tco(quadlet_t *tco_data, signed int size) |
---|
| 219 | { |
---|
| 220 | // Writes data to the TCO. No check is made as to whether a TCO |
---|
| 221 | // is present in the current device. Return value is 0 on success |
---|
| 222 | // or -1 on error. The first 4 quadlets of tco_data are significant; |
---|
| 223 | // all others are ignored. If fewer than 4 quadlets are supplied (as |
---|
| 224 | // indicated by the "size" parameter, -1 will be returned. |
---|
| 225 | if (size < 4) |
---|
| 226 | return -1; |
---|
| 227 | |
---|
| 228 | // Don't bother trying to write if the device is a FF400 since the TCO |
---|
| 229 | // can't be fitted to this device. |
---|
| 230 | if (m_rme_model==RME_MODEL_FIREFACE400) |
---|
| 231 | return -1; |
---|
| 232 | |
---|
| 233 | if (writeBlock(RME_FF_TCO_WRITE_REG, tco_data, 4) != 0) |
---|
| 234 | return -1; |
---|
| 235 | |
---|
| 236 | return 0; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | } |
---|