From patchwork Fri Aug 9 17:14:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2842513 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58B2EBF546 for ; Sat, 10 Aug 2013 18:21:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2592A2029B for ; Sat, 10 Aug 2013 18:21:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 271DF2027F for ; Sat, 10 Aug 2013 18:21:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13396E69D4 for ; Sat, 10 Aug 2013 11:21:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [95.142.166.194]) by gabe.freedesktop.org (Postfix) with ESMTP id 6571CE6AA1 for ; Fri, 9 Aug 2013 10:14:22 -0700 (PDT) Received: from avalon.ideasonboard.com (unknown [109.134.65.8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 79DCA36702; Fri, 9 Aug 2013 19:14:02 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH/RFC v3 03/19] video: display: Add video and stream control operations Date: Fri, 9 Aug 2013 19:14:54 +0200 Message-Id: <1376068510-30363-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1376068510-30363-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1376068510-30363-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailman-Approved-At: Sat, 10 Aug 2013 11:06:24 -0700 Cc: Sebastien Guiriec , Jesse Barnes , Benjamin Gaignard , Tom Gall , Kyungmin Park , Tomi Valkeinen , Stephen Warren , Mark Zhang , =?UTF-8?q?St=C3=A9phane=20Marchesin?= , Alexandre Courbot , Ragesh Radhakrishnan , Thomas Petazzoni , Sunil Joshi , Maxime Ripard , Vikas Sajjan , Marcus Lorentzon X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The video and stream control operations handle video stream management, both from the control point of view (called in response to userspace requests) and the video stream point of view (called by entities to control the video stream they receive on their input(s)). Signed-off-by: Laurent Pinchart --- drivers/video/display/display-core.c | 82 ++++++++++++++++++++++++++++++++++++ include/video/display.h | 49 +++++++++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/drivers/video/display/display-core.c b/drivers/video/display/display-core.c index 82fc58b..bb18723 100644 --- a/drivers/video/display/display-core.c +++ b/drivers/video/display/display-core.c @@ -25,6 +25,57 @@ */ /** + * display_entity_set_state - Set the display entity operation state + * @entity: The display entity + * @state: Display entity operation state + * + * See &enum display_entity_state for information regarding the entity states. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_set_state(struct display_entity *entity, + enum display_entity_state state) +{ + int ret; + + if (entity->state == state) + return 0; + + if (!entity->ops->ctrl || !entity->ops->ctrl->set_state) + return 0; + + ret = entity->ops->ctrl->set_state(entity, state); + if (ret < 0) + return ret; + + entity->state = state; + return 0; +} +EXPORT_SYMBOL_GPL(display_entity_set_state); + +/** + * display_entity_update - Update the display + * @entity: The display entity + * + * Make the display entity ready to receive pixel data and start frame transfer. + * This operation can only be called if the display entity is in STANDBY or ON + * state. + * + * The display entity will call the upstream entity in the video chain to start + * the video stream. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_update(struct display_entity *entity) +{ + if (!entity->ops->ctrl || !entity->ops->ctrl->update) + return 0; + + return entity->ops->ctrl->update(entity); +} +EXPORT_SYMBOL_GPL(display_entity_update); + +/** * display_entity_get_modes - Get video modes supported by the display entity * @entity: The display entity * @port: The display entity port @@ -95,6 +146,36 @@ int display_entity_get_params(struct display_entity *entity, unsigned int port, EXPORT_SYMBOL_GPL(display_entity_get_params); /* ----------------------------------------------------------------------------- + * Video operations + */ + +/** + * display_entity_set_stream - Control the video stream state + * @entity: The display entity + * @port: The display entity port + * @state: Display video stream state + * + * Control the video stream state at the entity video output. + * + * See &enum display_entity_stream_state for information regarding the stream + * states. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_set_stream(struct display_entity *entity, unsigned int port, + enum display_entity_stream_state state) +{ + if (port >= entity->entity.num_pads) + return -EINVAL; + + if (!entity->ops->video || !entity->ops->video->set_stream) + return 0; + + return entity->ops->video->set_stream(entity, port, state); +} +EXPORT_SYMBOL_GPL(display_entity_set_stream); + +/* ----------------------------------------------------------------------------- * Connections */ @@ -177,6 +258,7 @@ int display_entity_init(struct display_entity *entity, unsigned int num_sinks, int ret; kref_init(&entity->ref); + entity->state = DISPLAY_ENTITY_STATE_OFF; num_pads = num_sinks + num_sources; pads = kzalloc(sizeof(*pads) * num_pads, GFP_KERNEL); diff --git a/include/video/display.h b/include/video/display.h index 74b227d..fef05a68 100644 --- a/include/video/display.h +++ b/include/video/display.h @@ -25,6 +25,38 @@ struct display_entity; struct videomode; +/** + * enum display_entity_state - State of a display entity + * @DISPLAY_ENTITY_STATE_OFF: The entity is turned off completely, possibly + * including its power supplies. Communication with a display entity in + * that state is not possible. + * @DISPLAY_ENTITY_STATE_STANDBY: The entity is in a low-power state. Full + * communication with the display entity is supported, including pixel data + * transfer, but the output is kept blanked. + * @DISPLAY_ENTITY_STATE_ON: The entity is fully operational. + */ +enum display_entity_state { + DISPLAY_ENTITY_STATE_OFF, + DISPLAY_ENTITY_STATE_STANDBY, + DISPLAY_ENTITY_STATE_ON, +}; + +/** + * enum display_entity_stream_state - State of a video stream + * @DISPLAY_ENTITY_STREAM_STOPPED: The video stream is stopped, no frames are + * transferred. + * @DISPLAY_ENTITY_STREAM_SINGLE_SHOT: The video stream has been started for + * single shot operation. The source entity will transfer a single frame + * and then stop. + * @DISPLAY_ENTITY_STREAM_CONTINUOUS: The video stream is running, frames are + * transferred continuously by the source entity. + */ +enum display_entity_stream_state { + DISPLAY_ENTITY_STREAM_STOPPED, + DISPLAY_ENTITY_STREAM_SINGLE_SHOT, + DISPLAY_ENTITY_STREAM_CONTINUOUS, +}; + enum display_entity_interface_type { DISPLAY_ENTITY_INTERFACE_DPI, DISPLAY_ENTITY_INTERFACE_DBI, @@ -39,6 +71,9 @@ struct display_entity_interface_params { struct display_entity_control_ops { int (*get_size)(struct display_entity *ent, unsigned int *width, unsigned int *height); + int (*set_state)(struct display_entity *ent, + enum display_entity_state state); + int (*update)(struct display_entity *ent); /* Port operations */ int (*get_modes)(struct display_entity *entity, unsigned int port, @@ -47,8 +82,14 @@ struct display_entity_control_ops { struct display_entity_interface_params *params); }; +struct display_entity_video_ops { + int (*set_stream)(struct display_entity *ent, unsigned int port, + enum display_entity_stream_state state); +}; + struct display_entity_ops { const struct display_entity_control_ops *ctrl; + const struct display_entity_video_ops *video; }; struct display_entity { @@ -63,6 +104,8 @@ struct display_entity { const struct display_entity_ops *ops; void(*release)(struct display_entity *ent); + + enum display_entity_state state; }; static inline struct display_entity * @@ -86,9 +129,15 @@ void display_entity_put(struct display_entity *entity); int display_entity_get_size(struct display_entity *entity, unsigned int *width, unsigned int *height); +int display_entity_set_state(struct display_entity *entity, + enum display_entity_state state); +int display_entity_update(struct display_entity *entity); int display_entity_get_modes(struct display_entity *entity, unsigned int port, const struct videomode **modes); int display_entity_get_params(struct display_entity *entity, unsigned int port, struct display_entity_interface_params *params); +int display_entity_set_stream(struct display_entity *entity, unsigned int port, + enum display_entity_stream_state state); + #endif /* __DISPLAY_H__ */