media: allegro: add field for number of buffers
authorMichael Tretter <m.tretter@pengutronix.de>
Mon, 13 Jul 2020 14:42:21 +0000 (16:42 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sun, 19 Jul 2020 12:00:31 +0000 (14:00 +0200)
When pushing the buffers for the intermediate and reference frames to
the MCU, the driver relied on the message size to calculate the number
of buffers. As it is not necessary anymore to keep the messages binary
compatible to the firmware, we can just explicitly write the number of
buffers into the message.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/allegro-dvt/allegro-core.c
drivers/staging/media/allegro-dvt/allegro-mail.c
drivers/staging/media/allegro-dvt/allegro-mail.h

index 6334b351ee3b00e9394bc93b36a2274ea6938595..6745a5fa11677b7b71188ab19131410f0fcc20d3 100644 (file)
@@ -1115,6 +1115,7 @@ static int allegro_mcu_push_buffer_internal(struct allegro_channel *channel,
        msg->header.length = size - sizeof(msg->header);
        msg->header.type = type;
        msg->channel_id = channel->mcu_channel_id;
+       msg->num_buffers = num_buffers;
 
        buffer = msg->buffer;
        list_for_each_entry(al_buffer, list, head) {
index c78367d36e2e59d45bd7800ed0a2bba81c897c27..ba1c3bc587c691f71e6be61211b2333635bf13f2 100644 (file)
@@ -156,7 +156,7 @@ allegro_enc_push_buffers(u32 *dst, struct mcu_msg_push_buffers_internal *msg)
 {
        unsigned int i = 0;
        struct mcu_msg_push_buffers_internal_buffer *buffer;
-       unsigned int num_buffers = (msg->header.length - 4) / sizeof(*buffer);
+       unsigned int num_buffers = msg->num_buffers;
        unsigned int j;
 
        dst[i++] = msg->channel_id;
index 457caf50ebe6b225132e538d520a55eeb4d1d91e..14b54eb524889f464420639978b7e4605b87dc7f 100644 (file)
@@ -169,6 +169,7 @@ struct mcu_msg_push_buffers_internal_buffer {
 struct mcu_msg_push_buffers_internal {
        struct mcu_msg_header header;
        u32 channel_id;
+       size_t num_buffers;
        struct mcu_msg_push_buffers_internal_buffer buffer[];
 } __attribute__ ((__packed__));