From patchwork Mon Jul 13 14:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 11659947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 148DD13A4 for ; Mon, 13 Jul 2020 14:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 058802082F for ; Mon, 13 Jul 2020 14:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729983AbgGMOmf (ORCPT ); Mon, 13 Jul 2020 10:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729992AbgGMOmd (ORCPT ); Mon, 13 Jul 2020 10:42:33 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77908C08C5E3 for ; Mon, 13 Jul 2020 07:42:33 -0700 (PDT) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juzf5-0001mV-M8; Mon, 13 Jul 2020 16:42:31 +0200 Received: from mtr by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1juzf4-0007rn-NP; Mon, 13 Jul 2020 16:42:30 +0200 From: Michael Tretter To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , kernel@pengutronix.de, Michael Tretter Subject: [PATCH v2 08/12] media: allegro: add config blob for channel Date: Mon, 13 Jul 2020 16:42:25 +0200 Message-Id: <20200713144229.30057-9-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713144229.30057-1-m.tretter@pengutronix.de> References: <20200713144229.30057-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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: Michael Tretter --- Changelog: v1 -> v2: - add missing string.h --- .../staging/media/allegro-dvt/allegro-core.c | 20 ++++++++++++++++++- .../staging/media/allegro-dvt/allegro-mail.c | 18 +++++++++++------ .../staging/media/allegro-dvt/allegro-mail.h | 9 ++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c index e6d64151e4fe..51e85cad9941 100644 --- a/drivers/staging/media/allegro-dvt/allegro-core.c +++ b/drivers/staging/media/allegro-dvt/allegro-core.c @@ -206,6 +206,8 @@ struct allegro_channel { unsigned int cpb_size; unsigned int gop_size; + struct allegro_buffer config_blob; + struct v4l2_ctrl *mpeg_video_h264_profile; struct v4l2_ctrl *mpeg_video_h264_level; struct v4l2_ctrl *mpeg_video_h264_i_frame_qp; @@ -978,6 +980,14 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev, struct allegro_channel *channel) { struct mcu_msg_create_channel msg; + struct allegro_buffer *blob = &channel->config_blob; + struct create_channel_param param; + size_t size; + + memset(¶m, 0, sizeof(param)); + fill_create_channel_param(channel, ¶m); + allegro_alloc_buffer(dev, blob, sizeof(struct create_channel_param)); + size = allegro_encode_config_blob(blob->vaddr, ¶m); memset(&msg, 0, sizeof(msg)); @@ -986,7 +996,9 @@ static int allegro_mcu_send_create_channel(struct allegro_dev *dev, 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); @@ -1596,6 +1608,7 @@ allegro_handle_create_channel(struct allegro_dev *dev, { struct allegro_channel *channel; int err = 0; + struct create_channel_param param; channel = allegro_find_channel_by_user_id(dev, msg->user_id); if (IS_ERR(channel)) { @@ -1621,6 +1634,11 @@ allegro_handle_create_channel(struct allegro_dev *dev, "user %d: channel has channel id %d\n", channel->user_id, channel->mcu_channel_id); + err = allegro_decode_config_blob(¶m, msg, channel->config_blob.vaddr); + allegro_free_buffer(channel->dev, &channel->config_blob); + if (err) + goto out; + v4l2_dbg(1, debug, &dev->v4l2_dev, "channel %d: intermediate buffers: %d x %d bytes\n", channel->mcu_channel_id, diff --git a/drivers/staging/media/allegro-dvt/allegro-mail.c b/drivers/staging/media/allegro-dvt/allegro-mail.c index 7121f128aff3..c55b9339f9c6 100644 --- a/drivers/staging/media/allegro-dvt/allegro-mail.c +++ b/drivers/staging/media/allegro-dvt/allegro-mail.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "allegro-mail.h" @@ -65,8 +66,8 @@ static inline u32 settings_get_mcu_codec(struct create_channel_param *param) } } -static ssize_t -allegro_encode_channel_config(u32 *dst, struct create_channel_param *param) +ssize_t +allegro_encode_config_blob(u32 *dst, struct create_channel_param *param) { unsigned int i = 0; u32 val; @@ -158,18 +159,23 @@ allegro_encode_channel_config(u32 *dst, struct create_channel_param *param) static ssize_t 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; dst[i++] = msg->user_id; - size = allegro_encode_channel_config(&dst[i], param); - i += size / sizeof(*dst); + memcpy(&dst[i], msg->blob, msg->blob_size); + i += msg->blob_size / 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 allegro_enc_destroy_channel(u32 *dst, struct mcu_msg_destroy_channel *msg) { diff --git a/drivers/staging/media/allegro-dvt/allegro-mail.h b/drivers/staging/media/allegro-dvt/allegro-mail.h index 239fd8a20a69..07ed0a8d3de3 100644 --- a/drivers/staging/media/allegro-dvt/allegro-mail.h +++ b/drivers/staging/media/allegro-dvt/allegro-mail.h @@ -116,7 +116,9 @@ struct create_channel_param { struct mcu_msg_create_channel { struct mcu_msg_header header; u32 user_id; - struct create_channel_param param; + u32 *blob; + size_t blob_size; + u32 blob_mcu_addr; }; struct mcu_msg_create_channel_response { @@ -249,6 +251,11 @@ union mcu_msg_response { 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); ssize_t allegro_encode_mail(u32 *dst, void *msg);