From patchwork Tue Oct 11 14:54:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Starkey X-Patchwork-Id: 37423 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btyTq-0000dC-5h; Tue, 11 Oct 2016 14:56:34 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-7) with esmtp id 1btyTo-0005Lh-0O; Tue, 11 Oct 2016 16:56:34 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753722AbcJKO4J (ORCPT + 1 other); Tue, 11 Oct 2016 10:56:09 -0400 Received: from foss.arm.com ([217.140.101.70]:35600 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752778AbcJKOyp (ORCPT ); Tue, 11 Oct 2016 10:54:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F90E14FF; Tue, 11 Oct 2016 07:54:27 -0700 (PDT) Received: from e106950-lin.cambridge.arm.com (e106950-lin.cambridge.arm.com [10.2.133.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 05F473F32C; Tue, 11 Oct 2016 07:54:25 -0700 (PDT) From: Brian Starkey To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, liviu.dudau@arm.com, robdclark@gmail.com, hverkuil@xs4all.nl, eric@anholt.net, ville.syrjala@linux.intel.com, daniel@ffwll.ch Subject: [RFC PATCH 07/11] drm: Add writeback-connector pixel format properties Date: Tue, 11 Oct 2016 15:54:04 +0100 Message-Id: <1476197648-24918-8-git-send-email-brian.starkey@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1476197648-24918-1-git-send-email-brian.starkey@arm.com> References: <1476197648-24918-1-git-send-email-brian.starkey@arm.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.10.11.144516 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_NEGATE 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_POSSIBLE_EXPLOIT_SUBJ 0, __CP_URI_IN_BODY 0, __FROM_DOMAIN_IN_ANY_CC2 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0' So that userspace can determine what pixel formats are supported for a writeback connector's framebuffer, add a pixel format list to writeback connectors. This is in the form of an immutable blob containing an array of formats, and an immutable uint holding the array size. Signed-off-by: Brian Starkey --- drivers/gpu/drm/drm_connector.c | 73 ++++++++++++++++++++++++++++++++++++++- include/drm/drm_connector.h | 12 +++++++ include/drm/drm_crtc.h | 12 +++++++ 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index fb83870..2f1f61d 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -249,9 +249,14 @@ int drm_connector_init(struct drm_device *dev, drm_object_attach_property(&connector->base, config->prop_crtc_id, 0); } - if (connector_type == DRM_MODE_CONNECTOR_WRITEBACK) + if (connector_type == DRM_MODE_CONNECTOR_WRITEBACK) { drm_object_attach_property(&connector->base, config->prop_fb_id, 0); + drm_object_attach_property(&connector->base, + config->pixel_formats_property, 0); + drm_object_attach_property(&connector->base, + config->pixel_formats_size_property, 0); + } connector->debugfs_entry = NULL; out_put_type_id: @@ -851,6 +856,45 @@ int drm_mode_create_suggested_offset_properties(struct drm_device *dev) EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties); /** + * drm_mode_create_writeback_connector_properties - create writeback connector properties + * @dev: DRM device + * + * Create the properties specific to writeback connectors. These will be attached + * to writeback connectors by drm_connector_init. Drivers can set these + * properties using drm_mode_connector_set_writeback_formats(). + * + * "PIXEL_FORMATS": + * Immutable blob property to store the supported pixel formats table. The + * data is an array of u32 DRM_FORMAT_* fourcc values. + * Userspace can use this blob to find out what pixel formats are supported + * by the connector's writeback engine. + * + * "PIXEL_FORMATS_SIZE": + * Immutable unsigned range property storing the number of entries in the + * PIXEL_FORMATS array. + */ +int drm_mode_create_writeback_connector_properties(struct drm_device *dev) +{ + if (dev->mode_config.pixel_formats_property && + dev->mode_config.pixel_formats_size_property) + return 0; + + dev->mode_config.pixel_formats_property = + drm_property_create(dev, DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, + "PIXEL_FORMATS", 0); + + dev->mode_config.pixel_formats_size_property = + drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, + "PIXEL_FORMATS_SIZE", 0, UINT_MAX); + + if (dev->mode_config.pixel_formats_property == NULL || + dev->mode_config.pixel_formats_size_property == NULL) + return -ENOMEM; + return 0; +} +EXPORT_SYMBOL(drm_mode_create_writeback_connector_properties); + +/** * drm_mode_connector_set_path_property - set tile property on connector * @connector: connector to set property on. * @path: path to use for property; must not be NULL. @@ -957,6 +1001,33 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_mode_connector_update_edid_property); +int drm_mode_connector_set_writeback_formats(struct drm_connector *connector, + u32 *formats, + unsigned int n_formats) +{ + struct drm_device *dev = connector->dev; + size_t size = n_formats * sizeof(*formats); + int ret; + + if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) + return -EINVAL; + + ret = drm_property_replace_global_blob(dev, + &connector->pixel_formats_blob_ptr, + size, + formats, + &connector->base, + dev->mode_config.pixel_formats_property); + + if (!ret) + drm_object_property_set_value(&connector->base, + dev->mode_config.pixel_formats_size_property, + n_formats); + + return 0; +} +EXPORT_SYMBOL(drm_mode_connector_set_writeback_formats); + int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, struct drm_property *property, uint64_t value) diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 30a766a..e77ae5c 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -615,6 +615,14 @@ struct drm_connector { */ struct drm_property_blob *tile_blob_ptr; + /** + * @pixel_formats_blob_ptr + * + * DRM blob property data for the pixel formats list on writeback + * connectors + */ + struct drm_property_blob *pixel_formats_blob_ptr; + /* should we poll this connector for connects and disconnects */ /* hot plug detectable */ #define DRM_CONNECTOR_POLL_HPD (1 << 0) @@ -757,12 +765,16 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int drm_mode_create_scaling_mode_property(struct drm_device *dev); int drm_mode_create_aspect_ratio_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); +int drm_mode_create_writeback_connector_properties(struct drm_device *dev); int drm_mode_connector_set_path_property(struct drm_connector *connector, const char *path); int drm_mode_connector_set_tile_property(struct drm_connector *connector); int drm_mode_connector_update_edid_property(struct drm_connector *connector, const struct edid *edid); +int drm_mode_connector_set_writeback_formats(struct drm_connector *connector, + u32 *formats, + unsigned int n_formats); /** * drm_for_each_connector - iterate over all connectors diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 61932f5..c4a3164 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1302,6 +1302,18 @@ struct drm_mode_config { */ struct drm_property *suggested_y_property; + /** + * @pixel_formats_property: Property for writeback connectors, storing + * an array of the supported pixel formats for the writeback engine + * (read-only). + */ + struct drm_property *pixel_formats_property; + /** + * @pixel_formats_size_property: Property for writeback connectors, + * stating the size of the pixel formats array (read-only). + */ + struct drm_property *pixel_formats_size_property; + /* dumb ioctl parameters */ uint32_t preferred_depth, prefer_shadow;