Commit c4756d87 authored by Michael Tretter's avatar Michael Tretter Committed by Mauro Carvalho Chehab

media: allegro: add config blob for channel

Firmware versions >= 2019.2 do not configure the channel via the mailbox
interface anymore, but use a separate chunk of memory that is only
referenced by the message. As the configuration must be in a format that
is understood by the firmware and this format can change between
firmware versions, handle it similar to the message and treat is as a
blob.

In order to support both methods in the driver, always use a separate
blob for the channel configuration and copy that blob into the mailbox
if the firmware requires it and otherwise reference it.
Signed-off-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent d30e8412
...@@ -206,6 +206,8 @@ struct allegro_channel { ...@@ -206,6 +206,8 @@ struct allegro_channel {
unsigned int cpb_size; unsigned int cpb_size;
unsigned int gop_size; unsigned int gop_size;
struct allegro_buffer config_blob;
struct v4l2_ctrl *mpeg_video_h264_profile; struct v4l2_ctrl *mpeg_video_h264_profile;
struct v4l2_ctrl *mpeg_video_h264_level; struct v4l2_ctrl *mpeg_video_h264_level;
struct v4l2_ctrl *mpeg_video_h264_i_frame_qp; struct v4l2_ctrl *mpeg_video_h264_i_frame_qp;
...@@ -978,6 +980,14 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev, ...@@ -978,6 +980,14 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev,
struct allegro_channel *channel) struct allegro_channel *channel)
{ {
struct mcu_msg_create_channel msg; struct mcu_msg_create_channel msg;
struct allegro_buffer *blob = &channel->config_blob;
struct create_channel_param param;
size_t size;
memset(&param, 0, sizeof(param));
fill_create_channel_param(channel, &param);
allegro_alloc_buffer(dev, blob, sizeof(struct create_channel_param));
size = allegro_encode_config_blob(blob->vaddr, &param);
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
...@@ -986,7 +996,9 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev, ...@@ -986,7 +996,9 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev,
msg.user_id = channel->user_id; msg.user_id = channel->user_id;
fill_create_channel_param(channel, &msg.param); msg.blob = blob->vaddr;
msg.blob_size = size;
msg.blob_mcu_addr = to_mcu_addr(dev, blob->paddr);
allegro_mbox_send(dev->mbox_command, &msg); allegro_mbox_send(dev->mbox_command, &msg);
...@@ -1596,6 +1608,7 @@ allegro_handle_create_channel(struct allegro_dev *dev, ...@@ -1596,6 +1608,7 @@ allegro_handle_create_channel(struct allegro_dev *dev,
{ {
struct allegro_channel *channel; struct allegro_channel *channel;
int err = 0; int err = 0;
struct create_channel_param param;
channel = allegro_find_channel_by_user_id(dev, msg->user_id); channel = allegro_find_channel_by_user_id(dev, msg->user_id);
if (IS_ERR(channel)) { if (IS_ERR(channel)) {
...@@ -1621,6 +1634,11 @@ allegro_handle_create_channel(struct allegro_dev *dev, ...@@ -1621,6 +1634,11 @@ allegro_handle_create_channel(struct allegro_dev *dev,
"user %d: channel has channel id %d\n", "user %d: channel has channel id %d\n",
channel->user_id, channel->mcu_channel_id); channel->user_id, channel->mcu_channel_id);
err = allegro_decode_config_blob(&param, msg, channel->config_blob.vaddr);
allegro_free_buffer(channel->dev, &channel->config_blob);
if (err)
goto out;
v4l2_dbg(1, debug, &dev->v4l2_dev, v4l2_dbg(1, debug, &dev->v4l2_dev,
"channel %d: intermediate buffers: %d x %d bytes\n", "channel %d: intermediate buffers: %d x %d bytes\n",
channel->mcu_channel_id, channel->mcu_channel_id,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include "allegro-mail.h" #include "allegro-mail.h"
...@@ -65,8 +66,8 @@ static inline u32 settings_get_mcu_codec(struct create_channel_param *param) ...@@ -65,8 +66,8 @@ static inline u32 settings_get_mcu_codec(struct create_channel_param *param)
} }
} }
static ssize_t ssize_t
allegro_encode_channel_config(u32 *dst, struct create_channel_param *param) allegro_encode_config_blob(u32 *dst, struct create_channel_param *param)
{ {
unsigned int i = 0; unsigned int i = 0;
u32 val; u32 val;
...@@ -158,18 +159,23 @@ allegro_encode_channel_config(u32 *dst, struct create_channel_param *param) ...@@ -158,18 +159,23 @@ allegro_encode_channel_config(u32 *dst, struct create_channel_param *param)
static ssize_t static ssize_t
allegro_enc_create_channel(u32 *dst, struct mcu_msg_create_channel *msg) allegro_enc_create_channel(u32 *dst, struct mcu_msg_create_channel *msg)
{ {
struct create_channel_param *param = &msg->param;
ssize_t size = 0;
unsigned int i = 0; unsigned int i = 0;
dst[i++] = msg->user_id; dst[i++] = msg->user_id;
size = allegro_encode_channel_config(&dst[i], param); memcpy(&dst[i], msg->blob, msg->blob_size);
i += size / sizeof(*dst); i += msg->blob_size / sizeof(*dst);
return i * sizeof(*dst); return i * sizeof(*dst);
} }
ssize_t allegro_decode_config_blob(struct create_channel_param *param,
struct mcu_msg_create_channel_response *msg,
u32 *src)
{
return 0;
}
static ssize_t static ssize_t
allegro_enc_destroy_channel(u32 *dst, struct mcu_msg_destroy_channel *msg) allegro_enc_destroy_channel(u32 *dst, struct mcu_msg_destroy_channel *msg)
{ {
......
...@@ -116,7 +116,9 @@ struct create_channel_param { ...@@ -116,7 +116,9 @@ struct create_channel_param {
struct mcu_msg_create_channel { struct mcu_msg_create_channel {
struct mcu_msg_header header; struct mcu_msg_header header;
u32 user_id; u32 user_id;
struct create_channel_param param; u32 *blob;
size_t blob_size;
u32 blob_mcu_addr;
}; };
struct mcu_msg_create_channel_response { struct mcu_msg_create_channel_response {
...@@ -249,6 +251,11 @@ union mcu_msg_response { ...@@ -249,6 +251,11 @@ union mcu_msg_response {
struct mcu_msg_encode_frame_response encode_frame; struct mcu_msg_encode_frame_response encode_frame;
}; };
ssize_t allegro_encode_config_blob(u32 *dst, struct create_channel_param *param);
ssize_t allegro_decode_config_blob(struct create_channel_param *param,
struct mcu_msg_create_channel_response *msg,
u32 *src);
int allegro_decode_mail(void *msg, u32 *src); int allegro_decode_mail(void *msg, u32 *src);
ssize_t allegro_encode_mail(u32 *dst, void *msg); ssize_t allegro_encode_mail(u32 *dst, void *msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment