1.1 --- a/pkg/devices/lib/spi/src/jz4780.cc Sat Feb 03 16:38:58 2024 +0100
1.2 +++ b/pkg/devices/lib/spi/src/jz4780.cc Sun Feb 11 00:35:07 2024 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Perform SPI communication using the JZ4780/X1600 SPI peripheral.
1.6 *
1.7 - * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -292,7 +292,8 @@
1.13 return send_units(bytes, data, 1, 8, false);
1.14 }
1.15
1.16 -/* Transfer the given number of bytes from a buffer together with control values. */
1.17 +/* Transfer the given number of bytes from a buffer together with control
1.18 + values. Return the number of bytes transferred. */
1.19
1.20 uint32_t
1.21 Spi_jz4780_channel::send_dc(uint32_t bytes, const uint8_t data[],
1.22 @@ -325,7 +326,7 @@
1.23
1.24 /* Transfer the given number of bytes from a buffer using the given unit size in
1.25 bytes and character size in bits. The bytes are stored in a big endian
1.26 - arrangement. */
1.27 + arrangement. Return the number of bytes transferred. */
1.28
1.29 uint32_t
1.30 Spi_jz4780_channel::send_units(uint32_t bytes, const uint8_t data[],
1.31 @@ -357,7 +358,8 @@
1.32 }
1.33
1.34 /* Transfer the given number of bytes from a DMA region using the given
1.35 - unit size in bytes and character size in bits. */
1.36 + unit size in bytes and character size in bits. Return the number of bytes
1.37 + transferred. */
1.38
1.39 uint32_t
1.40 Spi_jz4780_channel::transfer(l4_addr_t vaddr,
1.41 @@ -386,8 +388,9 @@
1.42 unit_size, unit_size, unit_size,
1.43 _request_type, desc_vaddr, desc_paddr);
1.44
1.45 - /* Wait if not using a descriptor, which could be causing an endless,
1.46 - repeating transfer. */
1.47 + /* Wait if not using a descriptor, which could be configured in a cycle to
1.48 + cause an endless, repeating transfer, perhaps updating a display, for
1.49 + example. */
1.50
1.51 if (to_transfer && !desc_vaddr)
1.52 {
1.53 @@ -395,7 +398,7 @@
1.54 wait_busy();
1.55 }
1.56 else
1.57 - transferred = to_transfer;
1.58 + transferred = to_transfer * unit_size;
1.59
1.60 return transferred;
1.61 }