aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2021-09-08 15:41:20 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2021-09-08 15:41:20 +0200
commit36c1590096e8a057dff8272000b7994e17890993 (patch)
tree8dc0e4bca6eebc81ae0293d44a1284fd528143ad
parent7e47dbe2defd5c599997cf4309b1056186126415 (diff)
cobalt: debugging, trying to find kernel oopsextron
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--drivers/media/pci/cobalt/cobalt-alsa-pcm.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
index 9e7504e3cfd8..625510afead4 100644
--- a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
+++ b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
@@ -72,7 +72,49 @@ static const struct snd_pcm_hardware snd_cobalt_playback = {
.periods_max = 4,
};
-static void sample_cpy(u8 *dst, const u8 *src, u32 len, bool is_s32)
+static void sample_cpy1(u8 *dst, const u8 *src, u32 len, bool is_s32)
+{
+ static const unsigned map[8] = { 0, 1, 5, 4, 2, 3, 6, 7 };
+ unsigned idx = 0;
+
+ while (len >= (is_s32 ? 4 : 2)) {
+ unsigned offset = map[idx] * 4;
+ u32 val = src[offset + 1] + (src[offset + 2] << 8) +
+ (src[offset + 3] << 16);
+
+ if (is_s32) {
+ *dst++ = 0;
+ *dst++ = val & 0xff;
+ }
+ *dst++ = (val >> 8) & 0xff;
+ *dst++ = (val >> 16) & 0xff;
+ len -= is_s32 ? 4 : 2;
+ idx++;
+ }
+}
+
+static void sample_cpy2(u8 *dst, const u8 *src, u32 len, bool is_s32)
+{
+ static const unsigned map[8] = { 0, 1, 5, 4, 2, 3, 6, 7 };
+ unsigned idx = 0;
+
+ while (len >= (is_s32 ? 4 : 2)) {
+ unsigned offset = map[idx] * 4;
+ u32 val = src[offset + 1] + (src[offset + 2] << 8) +
+ (src[offset + 3] << 16);
+
+ if (is_s32) {
+ *dst++ = 0;
+ *dst++ = val & 0xff;
+ }
+ *dst++ = (val >> 8) & 0xff;
+ *dst++ = (val >> 16) & 0xff;
+ len -= is_s32 ? 4 : 2;
+ idx++;
+ }
+}
+
+static void sample_cpy3(u8 *dst, const u8 *src, u32 len, bool is_s32)
{
static const unsigned map[8] = { 0, 1, 5, 4, 2, 3, 6, 7 };
unsigned idx = 0;
@@ -140,32 +182,35 @@ static void cobalt_alsa_announce_pcm_data(struct snd_cobalt_card *cobsc,
}
oldptr = cobsc->hwptr_done_capture;
- if (oldptr + length >= runtime->buffer_size) {
+ WARN_ON(oldptr + length >= 2 * runtime->buffer_size);
+ if (oldptr + length > runtime->buffer_size) {
unsigned int cnt = runtime->buffer_size - oldptr;
unsigned i;
- for (i = 0; i < cnt; i++)
- sample_cpy(runtime->dma_area + (oldptr + i) * stride,
+ //pr_info("a %px %px %d %d %d %ld %d\n", runtime->dma_area, pcm_data, oldptr, length, stride, skip, runtime->buffer_size);
+ for (i = 0; i < cnt; i++) {
+ sample_cpy1(runtime->dma_area + (oldptr + i) * stride,
pcm_data + i * skip,
stride, is_s32);
- for (i = cnt; i < length; i++)
- sample_cpy(runtime->dma_area + (i - cnt) * stride,
+ }
+ for (i = cnt; i < length; i++) {
+ sample_cpy2(runtime->dma_area + (i - cnt) * stride,
pcm_data + i * skip, stride, is_s32);
+ }
} else {
unsigned i;
+ //pr_info("b %px %px %d %d %d %ld %d\n", runtime->dma_area, pcm_data, oldptr, length, stride, skip, runtime->buffer_size);
for (i = 0; i < length; i++)
- sample_cpy(runtime->dma_area + (oldptr + i) * stride,
+ sample_cpy3(runtime->dma_area + (oldptr + i) * stride,
pcm_data + i * skip,
stride, is_s32);
}
snd_pcm_stream_lock_irqsave(substream, flags);
cobsc->hwptr_done_capture += length;
- if (cobsc->hwptr_done_capture >=
- runtime->buffer_size)
- cobsc->hwptr_done_capture -=
- runtime->buffer_size;
+ if (cobsc->hwptr_done_capture >= runtime->buffer_size)
+ cobsc->hwptr_done_capture -= runtime->buffer_size;
cobsc->capture_transfer_done += length;
if (cobsc->capture_transfer_done >=

Privacy Policy