From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAF90CCFA00 for ; Sat, 1 Nov 2025 14:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ujNbH6eMg+bZNP2uEtVpGOtXkKxAPymum+xPkbbI+xM=; b=oEjyrdXOpSZJJMpruFupNWa1Dh XEIIV6DCUQSDAisc1Y9S4ivKgWe6FXlwzRMU3f3xVZ9HMqKy4NU5sNol2P401CQL0rs7wT+g79hYU st2FjNjFuNSu6sezaUr9IZsdxBLkHhvcsJ8cxMPEgyQ0FYOS5y3FBJvmlpxWl43fG1nJtPq45pBQW 2zsFSNL7EBViH9fRMoVOIYpB1OREpHIi9TLPfjefpuQN7S0shqpemZnuTfnv084copQeCXcIoh3aw RGmwvxW3FAHbY37IpGtCMDmi7MLt4+kKdjzWy0YDdKPOz6FkfUul4i9qGc2cZZtduq8U9mgPXzu3C N8xUINFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vFCD3-00000007p1D-1DTW; Sat, 01 Nov 2025 14:04:01 +0000 Received: from mout.gmx.net ([212.227.17.21]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vFCCz-00000007p0k-3Qic for linux-arm-kernel@lists.infradead.org; Sat, 01 Nov 2025 14:03:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1762005832; x=1762610632; i=wahrenst@gmx.net; bh=ujNbH6eMg+bZNP2uEtVpGOtXkKxAPymum+xPkbbI+xM=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=ny07hV6h75ptbUUpdbR0GosyzRNHLaHXgJvV7fHPnLbS62gF7szbkkH/a7oCIrIH djscwMDRG4eA3Em9rrS5vdhh5qtmW+3HpCk9huv0EV2o1pwKilb/s90aoqcZB+jIQ V1FCwiqczrJrhncAFIF2Mj1EB0uclDkC6sOf1ij/1V26Kw6VIums+8IsIFvxlfruf dyzx3pVQ9uc9NlJcsgp30AFXd/VKWOUSczsqw3o9sOGLHIZ/ut7liqV9VKJT9gWi0 bz9jz3FdmCjDhbFwaCePIeRKb2XuiNS6E2LcyDMmVqmlUVlHudWMzh10WK0NWr5AB +L3xbHftVhZkNgo7QA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.1.156] ([91.41.217.223]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MUGeB-1vfQ2V1h7D-00S6G9; Sat, 01 Nov 2025 15:03:52 +0100 Message-ID: Date: Sat, 1 Nov 2025 15:03:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/13] platform/raspberrypi: vchiq-mmal: Add support for event callbacks. To: Jai Luthra , Florian Fainelli , Raspberry Pi Kernel Maintenance , bcm-kernel-feedback-list@broadcom.com Cc: Dave Stevenson , Phil Elwell , Laurent Pinchart , Kieran Bingham , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson References: <20251031-b4-vc-sm-cma-v1-0-0dd5c0ec3f5c@ideasonboard.com> <20251031-b4-vc-sm-cma-v1-2-0dd5c0ec3f5c@ideasonboard.com> Content-Language: en-US From: Stefan Wahren Autocrypt: addr=wahrenst@gmx.net; keydata= xjMEZ1dOJBYJKwYBBAHaRw8BAQdA7H2MMG3q8FV7kAPko5vOAeaa4UA1I0hMgga1j5iYTTvN IFN0ZWZhbiBXYWhyZW4gPHdhaHJlbnN0QGdteC5uZXQ+wo8EExYIADcWIQT3FXg+ApsOhPDN NNFuwvLLwiAwigUCZ1dOJAUJB4TOAAIbAwQLCQgHBRUICQoLBRYCAwEAAAoJEG7C8svCIDCK JQ4BAP4Y9uuHAxbAhHSQf6UZ+hl5BDznsZVBJvH8cZe2dSZ6AQCNgoc1Lxw1tvPscuC1Jd1C TZomrGfQI47OiiJ3vGktBc44BGdXTiQSCisGAQQBl1UBBQEBB0B5M0B2E2XxySUQhU6emMYx f5QR/BrEK0hs3bLT6Hb9WgMBCAfCfgQYFggAJhYhBPcVeD4Cmw6E8M000W7C8svCIDCKBQJn V04kBQkHhM4AAhsMAAoJEG7C8svCIDCKJxoA/i+kqD5bphZEucrJHw77ujnOQbiKY2rLb0pE aHMQoiECAQDVbj827W1Yai/0XEABIr8Ci6a+/qZ8Vz6MZzL5GJosAA== In-Reply-To: <20251031-b4-vc-sm-cma-v1-2-0dd5c0ec3f5c@ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ZjHos8fjwumulL5HvaGO6HNrmXQkkEeNxLOKbg+NYCPR9449Es8 fjxM9yrrCORca7j2IMLSxnadCJ7sEoG54SKnLNOXslHYhVIh7KDcoGM3Lv2IDkrusIY/12E cq7BDcSSYN9lx2mfMYD2a1E2YpU5mcJKFtEmO39XbODYb29y4ixx9GEQ43zcgZX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BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251101_070358_739668_ED6EBA8A X-CRM114-Status: GOOD ( 25.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Am 31.10.25 um 18:27 schrieb Jai Luthra: > From: Dave Stevenson > > The codec uses the event mechanism to report things such as > resolution changes. It is signalled by the cmd field of the buffer > being non-zero. > > Add support for passing this information out to the client. > > Signed-off-by: Dave Stevenson > Signed-off-by: Jai Luthra > --- > drivers/platform/raspberrypi/vchiq-mmal/mmal-common.h | 1 + > drivers/platform/raspberrypi/vchiq-mmal/mmal-msg.h | 35 ++++++++++= +++++++++++++++ > drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c | 170 ++++++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++---------- > drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h | 4 +++ > 4 files changed, 196 insertions(+), 14 deletions(-) > > diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-common.h b/dri= vers/platform/raspberrypi/vchiq-mmal/mmal-common.h > index b33129403a30347fe762d0377cacbda77434c211..0443be8198ea57fcd66d598e= f7a46309d82ec7b7 100644 > --- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-common.h > +++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-common.h > @@ -50,6 +50,7 @@ struct mmal_buffer { > =20 > struct mmal_msg_context *msg_context; > =20 > + u32 cmd; /* MMAL command. 0=3Ddata. */ > unsigned long length; > u32 mmal_flags; > s64 dts; > diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-msg.h b/driver= s/platform/raspberrypi/vchiq-mmal/mmal-msg.h > index 1889494425eb65e4e2212e0806084a56087dc61d..7cccd5ee9a9e707b26dada6a= 9506d6a4145de32f 100644 > --- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-msg.h > +++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-msg.h > @@ -346,6 +346,41 @@ struct mmal_msg_port_parameter_get_reply { > /* event messages */ > #define MMAL_WORKER_EVENT_SPACE 256 > =20 > +/* Four CC's for events */ > +#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24)= ) This define already exists in vchiq-mmal/mmal-common.h > + > +#define MMAL_EVENT_ERROR MMAL_FOURCC('E', 'R', 'R', 'O') > +#define MMAL_EVENT_EOS MMAL_FOURCC('E', 'E', 'O', 'S') > +#define MMAL_EVENT_FORMAT_CHANGED MMAL_FOURCC('E', 'F', 'C', 'H') > +#define MMAL_EVENT_PARAMETER_CHANGED MMAL_FOURCC('E', 'P', 'C', 'H') > + > +/* Structs for each of the event message payloads */ > +struct mmal_msg_event_eos { > + u32 port_type; /**< Type of port that received the end of stream */ > + u32 port_index; /**< Index of port that received the end of stream */ > +}; > + > +/** Format changed event data. */ > +struct mmal_msg_event_format_changed { > + /* Minimum size of buffers the port requires */ > + u32 buffer_size_min; > + /* Minimum number of buffers the port requires */ > + u32 buffer_num_min; > + /* Size of buffers the port recommends for optimal performance. > + * A value of zero means no special recommendation. > + */ > + u32 buffer_size_recommended; > + /* Number of buffers the port recommends for optimal > + * performance. A value of zero means no special recommendation. > + */ > + u32 buffer_num_recommended; > + > + u32 es_ptr; I think it is necessary to explain what ES mean in this context. ptr=20 stands for pointer? > + struct mmal_es_format format; > + union mmal_es_specific_format es; > + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; > +}; > + > struct mmal_msg_event_to_host { > u32 client_component; /* component context */ > =20 > diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c b/driv= ers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c > index 82c2c261fd9cf0669cbd2ca7c814e0703317885a..a115a391908da06e101e1599= 05a4403b91e051c6 100644 > --- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c > +++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c > @@ -145,6 +145,8 @@ struct mmal_msg_context { > /* Presentation and Decode timestamps */ > s64 pts; > s64 dts; > + /* MMAL buffer command flag */ > + u32 cmd; > =20 > int status; /* context status */ > =20 > @@ -232,18 +234,6 @@ release_msg_context(struct mmal_msg_context *msg_co= ntext) > kfree(msg_context); > } > =20 > -/* deals with receipt of event to host message */ > -static void event_to_host_cb(struct vchiq_mmal_instance *instance, > - struct mmal_msg *msg, u32 msg_len) > -{ > - pr_debug("unhandled event\n"); > - pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n", > - msg->u.event_to_host.client_component, > - msg->u.event_to_host.port_type, > - msg->u.event_to_host.port_num, > - msg->u.event_to_host.cmd, msg->u.event_to_host.length); > -} > - > /* workqueue scheduled callback > * > * we do this because it is important we do not call any other vchiq > @@ -265,13 +255,18 @@ static void buffer_work_cb(struct work_struct *wor= k) > buffer->mmal_flags =3D msg_context->u.bulk.mmal_flags; > buffer->dts =3D msg_context->u.bulk.dts; > buffer->pts =3D msg_context->u.bulk.pts; > + buffer->cmd =3D msg_context->u.bulk.cmd; > =20 > - atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); > + if (!buffer->cmd) > + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); > =20 > msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance, > msg_context->u.bulk.port, > msg_context->u.bulk.status, > msg_context->u.bulk.buffer); > + > + if (buffer->cmd) > + mutex_unlock(&msg_context->u.bulk.port->event_context_mutex); > } > =20 > /* workqueue scheduled callback to handle receiving buffers > @@ -349,6 +344,7 @@ static int bulk_receive(struct vchiq_mmal_instance *= instance, > msg_context->u.bulk.buffer_used =3D rd_len; > msg_context->u.bulk.dts =3D msg->u.buffer_from_host.buffer_header.dts= ; > msg_context->u.bulk.pts =3D msg->u.buffer_from_host.buffer_header.pts= ; > + msg_context->u.bulk.cmd =3D msg->u.buffer_from_host.buffer_header.cmd; > =20 > queue_work(msg_context->instance->bulk_wq, > &msg_context->u.bulk.buffer_to_host_work); > @@ -451,6 +447,103 @@ buffer_from_host(struct vchiq_mmal_instance *insta= nce, > return ret; > } > =20 > +/* deals with receipt of event to host message */ > +static void event_to_host_cb(struct vchiq_mmal_instance *instance, > + struct mmal_msg *msg, u32 msg_len) > +{ > + /* FIXME: Not going to work on 64 bit */ > + struct vchiq_mmal_component *component =3D > + (struct vchiq_mmal_component *)msg->u.event_to_host.client_component; Please don't introduces FIXMEs and address them within the series.=20 Squash them. > + struct vchiq_mmal_port *port =3D NULL; > + struct mmal_msg_context *msg_context; > + u32 port_num =3D msg->u.event_to_host.port_num; > + > + if (msg->u.buffer_from_host.drvbuf.magic =3D=3D MMAL_MAGIC) { > + pr_err("%s: MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n", > + __func__); Please use dev_err and their equavilants. Didn't checkpatch complain here? > + return; > + } > + > + switch (msg->u.event_to_host.port_type) { > + case MMAL_PORT_TYPE_CONTROL: > + if (port_num) { > + pr_err("%s: port_num of %u >=3D number of ports 1", > + __func__, port_num); > + return; > + } > + port =3D &component->control; > + break; > + case MMAL_PORT_TYPE_INPUT: > + if (port_num >=3D component->inputs) { > + pr_err("%s: port_num of %u >=3D number of ports %u", > + __func__, port_num, > + port_num >=3D component->inputs); > + return; > + } > + port =3D &component->input[port_num]; > + break; > + case MMAL_PORT_TYPE_OUTPUT: > + if (port_num >=3D component->outputs) { > + pr_err("%s: port_num of %u >=3D number of ports %u", > + __func__, port_num, > + port_num >=3D component->outputs); > + return; > + } > + port =3D &component->output[port_num]; > + break; > + case MMAL_PORT_TYPE_CLOCK: > + if (port_num >=3D component->clocks) { > + pr_err("%s: port_num of %u >=3D number of ports %u", > + __func__, port_num, > + port_num >=3D component->clocks); > + return; > + } > + port =3D &component->clock[port_num]; > + break; > + default: > + break; > + } > + > + if (!mutex_trylock(&port->event_context_mutex)) { > + pr_err("dropping event 0x%x\n", msg->u.event_to_host.cmd); > + return; > + } > + msg_context =3D port->event_context; > + > + if (msg->h.status !=3D MMAL_MSG_STATUS_SUCCESS) { > + /* message reception had an error */ > + //pr_warn Please drop > + pr_err("%s: error %d in reply\n", __func__, msg->h.status); > + > + msg_context->u.bulk.status =3D msg->h.status; > + } else if (msg->u.event_to_host.length > MMAL_WORKER_EVENT_SPACE) { > + /* data is not in message, queue a bulk receive */ > + pr_err("%s: payload not in message - bulk receive??! NOT SUPPORTED\n"= , > + __func__); > + msg_context->u.bulk.status =3D -1; > + } else { > + memcpy(msg_context->u.bulk.buffer->buffer, > + msg->u.event_to_host.data, > + msg->u.event_to_host.length); > + > + msg_context->u.bulk.buffer_used =3D > + msg->u.event_to_host.length; > + > + msg_context->u.bulk.mmal_flags =3D 0; > + msg_context->u.bulk.dts =3D MMAL_TIME_UNKNOWN; > + msg_context->u.bulk.pts =3D MMAL_TIME_UNKNOWN; > + msg_context->u.bulk.cmd =3D msg->u.event_to_host.cmd; > + > + pr_debug("event component:%u port type:%d num:%d cmd:0x%x length:%d\n= ", > + msg->u.event_to_host.client_component, > + msg->u.event_to_host.port_type, > + msg->u.event_to_host.port_num, > + msg->u.event_to_host.cmd, msg->u.event_to_host.length); > + } > + > + schedule_work(&msg_context->u.bulk.work); > +} > + > /* deals with receipt of buffer to host message */ > static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, > struct mmal_msg *msg, u32 msg_len) > @@ -1333,6 +1426,7 @@ static int port_disable(struct vchiq_mmal_instance= *instance, > mmalbuf->mmal_flags =3D 0; > mmalbuf->dts =3D MMAL_TIME_UNKNOWN; > mmalbuf->pts =3D MMAL_TIME_UNKNOWN; > + mmalbuf->cmd =3D 0; > port->buffer_cb(instance, > port, 0, mmalbuf); > } > @@ -1634,6 +1728,43 @@ int mmal_vchi_buffer_cleanup(struct mmal_buffer *= buf) > } > EXPORT_SYMBOL_GPL(mmal_vchi_buffer_cleanup); > =20 > +static void init_event_context(struct vchiq_mmal_instance *instance, > + struct vchiq_mmal_port *port) > +{ > + struct mmal_msg_context *ctx =3D get_msg_context(instance); > + > + mutex_init(&port->event_context_mutex); > + > + port->event_context =3D ctx; > + ctx->u.bulk.instance =3D instance; > + ctx->u.bulk.port =3D port; > + ctx->u.bulk.buffer =3D > + kzalloc(sizeof(*ctx->u.bulk.buffer), GFP_KERNEL); > + if (!ctx->u.bulk.buffer) > + goto release_msg_context; Since this whole function can fail, it should return an error code. > + ctx->u.bulk.buffer->buffer =3D kzalloc(MMAL_WORKER_EVENT_SPACE, > + GFP_KERNEL); > + if (!ctx->u.bulk.buffer->buffer) > + goto release_buffer; > + > + INIT_WORK(&ctx->u.bulk.work, buffer_work_cb); > + return; > + > +release_buffer: > + kfree(ctx->u.bulk.buffer); > +release_msg_context: > + release_msg_context(ctx); > +} > + > +static void free_event_context(struct vchiq_mmal_port *port) > +{ > + struct mmal_msg_context *ctx =3D port->event_context; > + > + kfree(ctx->u.bulk.buffer->buffer); > + kfree(ctx->u.bulk.buffer); > + release_msg_context(ctx); > +} > + > /* Initialise a mmal component and its ports > * > */ > @@ -1683,6 +1814,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_in= stance *instance, > ret =3D port_info_get(instance, &component->control); > if (ret < 0) > goto release_component; > + init_event_context(instance, &component->control); > =20 > for (idx =3D 0; idx < component->inputs; idx++) { > component->input[idx].type =3D MMAL_PORT_TYPE_INPUT; > @@ -1693,6 +1825,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_in= stance *instance, > ret =3D port_info_get(instance, &component->input[idx]); > if (ret < 0) > goto release_component; > + init_event_context(instance, &component->input[idx]); > } > =20 > for (idx =3D 0; idx < component->outputs; idx++) { > @@ -1704,6 +1837,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_in= stance *instance, > ret =3D port_info_get(instance, &component->output[idx]); > if (ret < 0) > goto release_component; > + init_event_context(instance, &component->output[idx]); > } > =20 > for (idx =3D 0; idx < component->clocks; idx++) { > @@ -1715,6 +1849,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_in= stance *instance, > ret =3D port_info_get(instance, &component->clock[idx]); > if (ret < 0) > goto release_component; > + init_event_context(instance, &component->clock[idx]); > } > =20 > *component_out =3D component; > @@ -1740,7 +1875,7 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_component_init); > int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance= , > struct vchiq_mmal_component *component) > { > - int ret; > + int ret, idx; > =20 > if (mutex_lock_interruptible(&instance->vchiq_mutex)) > return -EINTR; > @@ -1752,6 +1887,13 @@ int vchiq_mmal_component_finalise(struct vchiq_mm= al_instance *instance, > =20 > component->in_use =3D false; > =20 > + for (idx =3D 0; idx < component->inputs; idx++) > + free_event_context(&component->input[idx]); > + for (idx =3D 0; idx < component->outputs; idx++) > + free_event_context(&component->output[idx]); > + for (idx =3D 0; idx < component->clocks; idx++) > + free_event_context(&component->clock[idx]); > + > mutex_unlock(&instance->vchiq_mutex); > =20 > return ret; > diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h b/driv= ers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h > index 8c3959f6f97fb21bcaf2f21589ef291e754e7c19..190a0f42bd6b22c7493463da= 94c094265d85d8fa 100644 > --- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h > +++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h > @@ -79,6 +79,10 @@ struct vchiq_mmal_port { > vchiq_mmal_buffer_cb buffer_cb; > /* callback context */ > void *cb_ctx; > + > + /* ensure serialised use of the one event context structure */ > + struct mutex event_context_mutex; > + struct mmal_msg_context *event_context; > }; > =20 > struct vchiq_mmal_component { >