diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-12-02 12:48:23 +0100 |
---|---|---|
committer | Dan Dennedy <dan@dennedy.org> | 2008-12-03 19:56:36 -0800 |
commit | fbe1fa46c66d45af8fb93cf82d4d4344cc6d431b (patch) | |
tree | 9045df29caacc8efcd99c4792b2b0825cb2a3eed | |
parent | 788442d4031ecf06f00415e865cdd776d3c579f2 (diff) | |
download | libraw1394-fbe1fa46c66d45af8fb93cf82d4d4344cc6d431b.tar.gz |
[libraw1394 patch] Unify {ieee1394,fw}_bandwidth_modify()
because they do the same.
We only may want a separate fw_bandwidth_modify() in the future when
firewire-core gains a special ioctl() for that.
(Not runtime-tested, but it looks good to me.)
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
-rw-r--r-- | src/dispatch.c | 5 | ||||
-rw-r--r-- | src/fw.c | 49 | ||||
-rw-r--r-- | src/fw.h | 3 |
3 files changed, 1 insertions, 56 deletions
diff --git a/src/dispatch.c b/src/dispatch.c index b5b123e..49ceca2 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -541,10 +541,7 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth, errno = EINVAL; return -1; } - if (handle->is_fw) - return fw_bandwidth_modify(handle, bandwidth, mode); - else - return ieee1394_bandwidth_modify(handle, bandwidth, mode); + return ieee1394_bandwidth_modify(handle, bandwidth, mode); } int raw1394_channel_modify (raw1394handle_t handle, unsigned int channel, @@ -1293,52 +1293,3 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, return 0; } - -#define MAXIMUM_BANDWIDTH 4915 - -int -fw_bandwidth_modify (raw1394handle_t handle, - unsigned int bandwidth, - enum raw1394_modify_mode mode) -{ - quadlet_t buffer, compare, swap; - nodeaddr_t addr; - int result; - - if (bandwidth == 0) - return 0; - - addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE; - /* Read current bandwidth usage from IRM. */ - result = raw1394_read (handle, raw1394_get_irm_id (handle), addr, - sizeof buffer, &buffer); - if (result < 0) - return -1; - - compare = ntohl (buffer); - switch (mode) { - case RAW1394_MODIFY_ALLOC: - if (compare < bandwidth) - return -1; - - swap = compare - bandwidth; - break; - - case RAW1394_MODIFY_FREE: - swap = compare + bandwidth; - if (swap > MAXIMUM_BANDWIDTH) - swap = MAXIMUM_BANDWIDTH; - break; - - default: - return -1; - } - - result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr, - RAW1394_EXTCODE_COMPARE_SWAP, - htonl(swap), htonl(compare), &buffer); - if (result < 0 || ntohl(buffer) != compare) - return -1; - - return 0; -} @@ -211,9 +211,6 @@ int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, unsigned char *rom_version); -int fw_bandwidth_modify (raw1394handle_t handle, - unsigned int bandwidth, - enum raw1394_modify_mode mode); int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, int prebuffer_packets); |