[PATCH v3 1/1] Documentation: drm: describing drm properties exposed by various drivers
From: Sagar Kamble Started documenting drm properties for drm drivers. This patch provides information about properties in drm, i915, psb and cdv/gma-500. Information about other properties can be added on top of these. v2: Added description of drm properties in armada, exynos, i2c/ch7006, noveau, omap, qxl, radeon, rcar-du v3: Removed "Property Object" column since it is implementation related. Property type column refined.[Ville's review comments] Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 1025 1 file changed, 1025 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index ed1d6d2..f38c505 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2317,6 +2317,1031 @@ void intel_crt_init(struct drm_device *dev) pointer to the target object, a pointer to the previously created property and an initial instance value. + + Following table gives description of drm properties exposed by various + modules/drivers. + + + + +Owner Module/Drivers +Group +Property Name +Type +Property Values +Object attached +Description/Restrictions + + + +DRM +Generic +?EDID? +BLOB | IMMUTABLE +0 +Connector +Contains id of edid blob ptr object. + + + +?DPMS? +ENUM +{ DRM_MODE_DPMS_ON, ?On?}, +{ DRM_MODE_DPMS_STANDBY, ?Standby?}, +{ DRM_MODE_DPMS_SUSPEND, ?Suspend?}, +{ DRM_MODE_DPMS_OFF, ?Off?} +Connector +Contains DPMS operation mode value. + + + +DVI-I +?subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Unknown, ?Unknown?}, +{ DRM_MODE_SUBCONNECTOR_DVID, ?DVI-D?}, +{ DRM_MODE_SUBCONNECTOR_DVIA, ?DVI-A?} +Connector +TBD + + + +?select subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Automatic, ?Automatic?}, +{ DRM_MODE_SUBCONNECTOR_DVID, ?DVI-D?}, +{ DRM_MODE_SUBCONNECTOR_DVIA, ?DVI-A?} +Connector +TBD + + + +TV +?subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Unknown, "Unknown"}, +{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, +{ DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO"}, +{ DRM_MODE_SUBCONNECTOR_Component , "Component"}, +{ DRM_MODE_SUBCONNECTOR_SCART, "SCART"} +Connector +TBD + + + +?select subconnector? +ENUM +{DRM_MODE_SUBCONNECTOR_Automatic, "Automatic"}, +{DRM_MODE_SUBCONNECTOR_Composite, "Composite"}, +{DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO"}, +{DRM_MODE_SUBCONNECTOR_Component, "Component"}, +{DRM_MODE_SUBCONNECTOR_SCART, "SCART"} +Connector +TBD + + + +?mode? +ENUM +{0, "NTSC_M"} , {1, "NTSC_J"} , +{2, "NTSC_443"}, {3, "PAL_B"} etc. +Connector +TBD + + + +?left margin? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?right margin? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?top margin? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?bottom margin? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?brightness? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?contrast? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?flicker reduction? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?overscan? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?saturation? +RANGE +Min=0, Max=100 +Connector +TBD + + + +?hue? +RANGE +Min=0, Max=100 +Connector +TBD + + + +Optional +?scaling mode? +ENUM +{ DRM_MODE_SCALE_NONE, "None" }, +{ DRM_MODE_SCALE_FULLSCREEN, "Full" }, +{ DRM_MODE_SCALE_CENTER, "Center" }, +{ DRM_MODE_SCALE_ASPECT, "Full aspect" } +Connector +TBD + + + +?dirty? +ENUM | IMMUTABLE +{ DRM_MODE_DIRTY_OFF, "Off" }, +{ DRM_MODE_DIRTY_ON, "On" }, +{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" } +Connector +TBD + + + +i915 +Generic +"Broadcast RGB" +ENUM +{ INTEL_BROADCAST_RGB_AUTO, "Automatic" }, +{ INTEL_BROADCAST_RGB_FULL, "Full" }, +{ INTEL_BROADCAST_RGB_LIMITED, "Limited 16:235" } +Connector +TBD + + + +?audio? +ENUM +{ HDMI_AUDIO_OFF_DVI, "force-dvi" }, +{ HDMI_AUDIO_OFF, "off" }, +{ HDMI_AUDIO_AUTO, "auto" }, +{ HDMI_AUDIO_ON, "on" } +Connector +TBD + + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + + +SDVO-TV +?mode? +ENUM +{0, "NTSC_M"} , {1, "NTSC_J"} , +{2, "NTSC_443"}, {3, "PAL_B"} etc. +Connector +TBD + + + +"left_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +"right_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +"top_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +"bottom_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?hpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?vpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?contrast? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?saturation? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?hue? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + + +?sharpn
[PATCH v4 1/1] Documentation: drm: describing drm properties exposed by various drivers
From: Sagar Kamble Started documenting drm properties for drm drivers. This patch provides information about properties in drm, i915, psb and cdv/gma-500. Information about other properties can be added on top of these. v2: Added description of drm properties in armada, exynos, i2c/ch7006, noveau, omap, qxl, radeon, rcar-du v3: Removed "Property Object" column since it is implementation related. Property type column refined.[Ville's review comments] v4: Removed whitespace warnings and minor nits. Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 913 + 1 file changed, 913 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index ed1d6d2..b810c77 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2317,6 +2317,919 @@ void intel_crt_init(struct drm_device *dev) pointer to the target object, a pointer to the previously created property and an initial instance value. + + The following table gives description of drm properties exposed by various + modules/drivers. + + + + +Owner Module/Drivers +Group +Property Name +Type +Property Values +Object attached +Description/Restrictions + + +DRM +Generic +?EDID? +BLOB | IMMUTABLE +0 +Connector +Contains id of edid blob ptr object. + + +?DPMS? +ENUM +{ DRM_MODE_DPMS_ON, ?On?}, +{ DRM_MODE_DPMS_STANDBY, ?Standby?}, +{ DRM_MODE_DPMS_SUSPEND, ?Suspend?}, +{ DRM_MODE_DPMS_OFF, ?Off?} +Connector +Contains DPMS operation mode value. + + +DVI-I +?subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Unknown, ?Unknown?}, +{ DRM_MODE_SUBCONNECTOR_DVID, ?DVI-D?}, +{ DRM_MODE_SUBCONNECTOR_DVIA, ?DVI-A?} +Connector +TBD + + +?select subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Automatic, ?Automatic?}, +{ DRM_MODE_SUBCONNECTOR_DVID, ?DVI-D?}, +{ DRM_MODE_SUBCONNECTOR_DVIA, ?DVI-A?} +Connector +TBD + + +TV +?subconnector? +ENUM +{ DRM_MODE_SUBCONNECTOR_Unknown, "Unknown"}, +{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, +{ DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO"}, +{ DRM_MODE_SUBCONNECTOR_Component , "Component"}, +{ DRM_MODE_SUBCONNECTOR_SCART, "SCART"} +Connector +TBD + + +?select subconnector? +ENUM +{DRM_MODE_SUBCONNECTOR_Automatic, "Automatic"}, +{DRM_MODE_SUBCONNECTOR_Composite, "Composite"}, +{DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO"}, +{DRM_MODE_SUBCONNECTOR_Component, "Component"}, +{DRM_MODE_SUBCONNECTOR_SCART, "SCART"} +Connector +TBD + + +?mode? +ENUM +{0, "NTSC_M"} , {1, "NTSC_J"} , +{2, "NTSC_443"}, {3, "PAL_B"} etc. +Connector +TBD + + +?left margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?right margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?top margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?bottom margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?brightness? +RANGE +Min=0, Max=100 +Connector +TBD + + +?contrast? +RANGE +Min=0, Max=100 +Connector +TBD + + +?flicker reduction? +RANGE +Min=0, Max=100 +Connector +TBD + + +?overscan? +RANGE +Min=0, Max=100 +Connector +TBD + + +?saturation? +RANGE +Min=0, Max=100 +Connector +TBD + + +?hue? +RANGE +Min=0, Max=100 +Connector +TBD + + +Optional +?scaling mode? +ENUM +{ DRM_MODE_SCALE_NONE, "None" }, +{ DRM_MODE_SCALE_FULLSCREEN, "Full" }, +{ DRM_MODE_SCALE_CENTER, "Center" }, +{ DRM_MODE_SCALE_ASPECT, "Full aspect" } +Connector +TBD + + +?dirty? +ENUM | IMMUTABLE +{ DRM_MODE_DIRTY_OFF, "Off" }, +{ DRM_MODE_DIRTY_ON, "On" }, +{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" } +Connector +TBD + + +i915 +Generic +"Broadcast RGB" +ENUM +{ INTEL_BROADCAST_RGB_AUTO, "Automatic" }, +{ INTEL_BROADCAST_RGB_FULL, "Full" }, +{ INTEL_BROADCAST_RGB_LIMITED, "Limited 16:235" } +Connector +TBD + + +?audio? +ENUM +{ HDMI_AUDIO_OFF_DVI, "force-dvi" }, +{ HDMI_AUDIO_OFF, "off" }, +{ HDMI_AUDIO_AUTO, "auto" }, +{ HDMI_AUDIO_ON, "on" } +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + +SDVO-TV +?mode? +ENUM +{0, "NTSC_M"} , {1, "NTSC_J"} , +{2, "NTSC_443"}, {3, "PAL_B"} etc. +Connector +TBD + + +"left_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"right_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"top_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"bottom_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?vpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?contrast? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?saturation? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hue? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?sharpness? +RANGE +Min=0, Max= SDVO dependent +Connect
[PATCH v5 1/1] Documentation: drm: describing drm properties exposed by various drivers
From: Sagar Kamble Started documenting drm properties for drm drivers. This patch provides information about properties in drm, i915, psb and cdv/gma-500. Information about other properties can be added on top of these. v2: Added description of drm properties in armada, exynos, i2c/ch7006, noveau, omap, qxl, radeon, rcar-du v3: Removed "Property Object" column since it is implementation related. Property type column refined.[Ville's review comments] v4: Removed whitespace warnings and minor nits. v5: Restructured output for ENUM properties Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 846 + 1 file changed, 846 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index ed1d6d2..5650d13 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2317,6 +2317,852 @@ void intel_crt_init(struct drm_device *dev) pointer to the target object, a pointer to the previously created property and an initial instance value. + + The following table gives description of drm properties exposed by various + modules/drivers. + + + + +Owner Module/Drivers +Group +Property Name +Type +Property Values +Object attached +Description/Restrictions + + +DRM +Generic +?EDID? +BLOB | IMMUTABLE +0 +Connector +Contains id of edid blob ptr object. + + +?DPMS? +ENUM +{ ?On?, ?Standby?, ?Suspend?, ?Off? } +Connector +Contains DPMS operation mode value. + + +DVI-I +?subconnector? +ENUM +{ ?Unknown?, ?DVI-D?, ?DVI-A? } +Connector +TBD + + +?select subconnector? +ENUM +{ ?Automatic?, ?DVI-D?, ?DVI-A? } +Connector +TBD + + +TV +?subconnector? +ENUM +{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" } +Connector +TBD + + +?select subconnector? +ENUM +{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" } +Connector +TBD + + +?mode? +ENUM +{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. +Connector +TBD + + +?left margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?right margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?top margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?bottom margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?brightness? +RANGE +Min=0, Max=100 +Connector +TBD + + +?contrast? +RANGE +Min=0, Max=100 +Connector +TBD + + +?flicker reduction? +RANGE +Min=0, Max=100 +Connector +TBD + + +?overscan? +RANGE +Min=0, Max=100 +Connector +TBD + + +?saturation? +RANGE +Min=0, Max=100 +Connector +TBD + + +?hue? +RANGE +Min=0, Max=100 +Connector +TBD + + +Optional +?scaling mode? +ENUM +{ "None", "Full", "Center", "Full aspect" } +Connector +TBD + + +?dirty? +ENUM | IMMUTABLE +{ "Off", "On", "Annotate" } +Connector +TBD + + +i915 +Generic +"Broadcast RGB" +ENUM +{ "Automatic", "Full", "Limited 16:235" } +Connector +TBD + + +?audio? +ENUM +{ "force-dvi", "off", "auto", "on" } +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + +SDVO-TV +?mode? +ENUM +{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. +Connector +TBD + + +"left_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"right_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"top_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"bottom_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?vpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?contrast? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?saturation? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hue? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?sharpness? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter_adaptive? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter_2d? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?tv_chroma_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?tv_luma_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?dot_crawl? +RANGE +Min=0, Max=1 +Connector +TBD + + +SDVO-TV/LVDS +?brightness? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +CDV gma-500 +Generic +"Broadcast RGB" +ENUM +{ ?Full?, ?Limited 16:235? } +Connector +TBD + + +"Broadcast RGB" +ENUM +{ ?off?, ?auto?, ?on? } +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + +Poulsbo +Generic +?backlight? +RANGE +Min=0, Max=100 +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as
[PATCH 1/4] drm: Added plane alpha and color blending property
From: Sagar Kamble This patch creates a generic blending enum property. Drivers may support subset of these values. Cc: airlied at linux.ie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 33 + include/drm/drm_crtc.h | 25 + 2 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4e43fc2..15281a3 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev) idr_destroy(&dev->mode_config.crtc_idr); } EXPORT_SYMBOL(drm_mode_config_cleanup); + +struct drm_property *drm_mode_create_blend_property(struct drm_device *dev, + unsigned int supported_factors) +{ + static const struct drm_prop_enum_list props[] = { + { DRM_BLEND_NONE, "none" }, + { DRM_BLEND_ZERO, "zero" }, + { DRM_BLEND_ONE,"one" }, + { DRM_BLEND_SRC_COLOR, "src-color" }, + { DRM_BLEND_ONE_MINUS_SRC_COLOR,"one-minus-src-color" }, + { DRM_BLEND_DST_COLOR, "dst-color" }, + { DRM_BLEND_ONE_MINUS_DST_COLOR,"one-minus-dst-color" }, + { DRM_BLEND_SRC_ALPHA, "src-alpha" }, + { DRM_BLEND_ONE_MINUS_SRC_ALPHA,"one-minus-src-alpha" }, + { DRM_BLEND_DST_ALPHA, "dst-alpha" }, + { DRM_BLEND_ONE_MINUS_DST_ALPHA,"one-minus-dst-alpha" }, + { DRM_BLEND_CONSTANT_COLOR, "constant-color" }, + { DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, "one-minus-constant-color" }, + { DRM_BLEND_CONSTANT_ALPHA, "constant-alpha" }, + { DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, "one-minus-constant-alpha" }, + { DRM_BLEND_SRC_ALPHA_SATURATE, "alpha-saturate" }, + { DRM_BLEND_SRC1_COLOR, "src1-color" }, + { DRM_BLEND_ONE_MINUS_SRC1_COLOR, "one-minus-src1-color" }, + { DRM_BLEND_SRC1_ALPHA, "src1-alpha" }, + { DRM_BLEND_ONE_MINUS_SRC1_ALPHA, "one-minus-src1-alpha" }, + { DRM_BLEND_PREMULTIPLIED_ALPHA,"pre-multiplied-alpha" } + }; + + return drm_property_create_bitmask(dev, 0, "blend", + props, ARRAY_SIZE(props), + supported_factors); +} +EXPORT_SYMBOL(drm_mode_create_blend_property); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 784a568..6c5847f 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -65,6 +65,29 @@ struct drm_object_properties { uint64_t values[DRM_OBJECT_MAX_PROPERTY]; }; +/* Blending property bits */ +#define DRM_BLEND_NONE 0 +#define DRM_BLEND_ZERO 1 +#define DRM_BLEND_ONE 2 +#define DRM_BLEND_SRC_COLOR3 +#define DRM_BLEND_ONE_MINUS_SRC_COLOR 4 +#define DRM_BLEND_DST_COLOR5 +#define DRM_BLEND_ONE_MINUS_DST_COLOR 6 +#define DRM_BLEND_SRC_ALPHA7 +#define DRM_BLEND_ONE_MINUS_SRC_ALPHA 8 +#define DRM_BLEND_DST_ALPHA9 +#define DRM_BLEND_ONE_MINUS_DST_ALPHA 10 +#define DRM_BLEND_CONSTANT_COLOR 11 +#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR 12 +#define DRM_BLEND_CONSTANT_ALPHA 13 +#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA 14 +#define DRM_BLEND_SRC_ALPHA_SATURATE 15 +#define DRM_BLEND_SRC1_COLOR 16 +#define DRM_BLEND_ONE_MINUS_SRC1_COLOR 17 +#define DRM_BLEND_SRC1_ALPHA 18 +#define DRM_BLEND_ONE_MINUS_SRC1_ALPHA 19 +#define DRM_BLEND_PREMULTIPLIED_ALPHA 20 + /* * Note on terminology: here, for brevity and convenience, we refer to connector * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, @@ -1179,6 +1202,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane); extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); +extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev, + unsigned int supported_factors); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH 4/4] Documentation: drm: describing plane alpha and color blending property
From: Sagar Kamble Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 5650d13..ba260e8 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2334,7 +2334,7 @@ void intel_crt_init(struct drm_device *dev) DRM -Generic +Generic ?EDID? BLOB | IMMUTABLE 0 @@ -2349,6 +2349,17 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. +?blend? +BITMASK +{ {0, "none"}, {1, "zero"}, {2, "one"}, {3, "src-color"}, {4, "one-minus-src-color"} +, {5, "dst-color"}, {6, "one-minus-dst-color"}, {7, "src-alpha"}, {8, "one-minus-src-alpha"}, {9, "dst-alpha"} +, {10, "one-minus-dst-alpha"}, {11, "constant-color"}, {12, "one-minus-constant-color"}, {13, "constant-alpha"} +, {14, "one-minus-constant-alpha"}, {15, "alpha-saturate"}, {16, "src1-color"}, {17, "one-minus-src1-color"} +, {18, "src1-alpha"}, {19, "one-minus-src1-alpha"}, {20, "pre-multiplied-alpha"} } +Plane +Contains plane alpha/color blending operation value. + + DVI-I ?subconnector? ENUM -- 1.8.5
[PATCH v3 1/1] drm/i915: Enabling 128x128 and 256x256 ARGB Cursor Support
From: Sagar Kamble With this patch we allow larger cursor planes of sizes 128x128 and 256x256. v2: Added more precise check on size while setting cursor plane. v3: Changes related to restructuring cursor size restrictions and DRM_DEBUG usage. Testcase: igt/kms_cursor_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: G, Pallavi Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 4 drivers/gpu/drm/i915/intel_display.c | 36 +++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 146609a..aee8258 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3551,7 +3551,11 @@ enum punit_power_well { /* New style CUR*CNTR flags */ #define CURSOR_MODE 0x27 #define CURSOR_MODE_DISABLE 0x00 +#define CURSOR_MODE_128_32B_AX 0x02 +#define CURSOR_MODE_256_32B_AX 0x03 #define CURSOR_MODE_64_32B_AX 0x07 +#define CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX) +#define CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX) #define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) #define MCURSOR_PIPE_SELECT (1 << 28) #define MCURSOR_PIPE_A 0x00 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 0868afb..e59e8fd 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7440,10 +7440,22 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR(pipe)); if (base) { cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + switch (width) { + case 64: + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + case 128: + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + case 256: + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + } cntl |= pipe << 28; /* Connect to correct pipe */ } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); @@ -7468,10 +7480,22 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR_IVB(pipe)); if (base) { cntl &= ~CURSOR_MODE; - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + switch (width) { + case 64: + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + case 128: + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + case 256: + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; + break; + } } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); cntl |= CURSOR_MODE_DISABLE; @@ -7567,9 +7591,11 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto finish; } - /* Currently we only support 64x64 cursors */ - if (width != 64 || height != 64) { - DRM_ERROR("we currently only support 64x64 cursors\n"); + /* Check for which cursor types we support */ + if (!((width == 64 && height == 64) || + (width == 128 && height == 128 && !IS_GEN2(dev)) || + (width == 256 && height == 256 && !IS_GEN2(dev { + DRM_DEBUG("Cursor dimension not supported\n"); return -EINVAL; } -- 1.8.5
[PATCH v4 1/1] drm/i915: Enabling 128x128 and 256x256 ARGB Cursor Support
From: Sagar Kamble With this patch we allow larger cursor planes of sizes 128x128 and 256x256. v2: Added more precise check on size while setting cursor plane. v3: Changes related to restructuring cursor size restrictions and DRM_DEBUG usage. v4: Indentation related changes for setting cursor control and implementing DRM_CAP_CURSOR_WIDTH and DRM_CAP_CURSOR_HEIGHT Testcase: igt/kms_cursor_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: G, Pallavi Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 4 +++ drivers/gpu/drm/i915/intel_display.c | 53 drivers/gpu/drm/i915/intel_drv.h | 7 + 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 146609a..aee8258 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3551,7 +3551,11 @@ enum punit_power_well { /* New style CUR*CNTR flags */ #define CURSOR_MODE 0x27 #define CURSOR_MODE_DISABLE 0x00 +#define CURSOR_MODE_128_32B_AX 0x02 +#define CURSOR_MODE_256_32B_AX 0x03 #define CURSOR_MODE_64_32B_AX 0x07 +#define CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX) +#define CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX) #define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) #define MCURSOR_PIPE_SELECT (1 << 28) #define MCURSOR_PIPE_A 0x00 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 0868afb..ec6a073 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7440,10 +7440,26 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR(pipe)); if (base) { cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + cntl |= MCURSOR_GAMMA_ENABLE; + + switch (width) { + case 64: + cntl |= CURSOR_MODE_64_ARGB_AX; + break; + case 128: + cntl |= CURSOR_MODE_128_ARGB_AX; + break; + case 256: + cntl |= CURSOR_MODE_256_ARGB_AX; + break; + default: + WARN_ON(1); + return; + } cntl |= pipe << 28; /* Connect to correct pipe */ } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); @@ -7468,10 +7484,25 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR_IVB(pipe)); if (base) { cntl &= ~CURSOR_MODE; - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + cntl |= MCURSOR_GAMMA_ENABLE; + switch (width) { + case 64: + cntl |= CURSOR_MODE_64_ARGB_AX; + break; + case 128: + cntl |= CURSOR_MODE_128_ARGB_AX; + break; + case 256: + cntl |= CURSOR_MODE_256_ARGB_AX; + break; + default: + WARN_ON(1); + return; + } } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); cntl |= CURSOR_MODE_DISABLE; @@ -7567,9 +7598,11 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto finish; } - /* Currently we only support 64x64 cursors */ - if (width != 64 || height != 64) { - DRM_ERROR("we currently only support 64x64 cursors\n"); + /* Check for which cursor types we support */ + if (!((width == 64 && height == 64) || + (width == 128 && height == 128 && !IS_GEN2(dev)) || + (width == 256 && height == 256 && !IS_GEN2(dev { + DRM_DEBUG("Cursor dimension not supported\n"); return -EINVAL; } @@ -10331,6 +10364,16 @@ static void intel
[PATCH v6 1/1] Documentation: drm: describing drm properties exposed by various drivers
From: Sagar Kamble Started documenting drm properties for drm drivers. This patch provides information about properties in drm, i915, psb and cdv/gma-500. Information about other properties can be added on top of these. v2: Added description of drm properties in armada, exynos, i2c/ch7006, noveau, omap, qxl, radeon, rcar-du v3: Removed "Property Object" column since it is implementation related. Property type column refined.[Ville's review comments] v4: Removed whitespace warnings and minor nits. [Randy's review comments] v5: Restructured output for ENUM properties v6: Review comments on formatting the table. [Laurent's review comments] Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 848 + 1 file changed, 848 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index ed1d6d2..ae5e606 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2317,6 +2317,854 @@ void intel_crt_init(struct drm_device *dev) pointer to the target object, a pointer to the previously created property and an initial instance value. + + + The following table gives description of drm properties exposed by various + modules/drivers. + + + + + +Owner Module/Drivers +Group +Property Name +Type +Property Values +Object attached +Description/Restrictions + + +DRM +Generic +?EDID? +BLOB | IMMUTABLE +0 +Connector +Contains id of edid blob ptr object. + + +?DPMS? +ENUM +{ ?On?, ?Standby?, ?Suspend?, ?Off? } +Connector +Contains DPMS operation mode value. + + +DVI-I +?subconnector? +ENUM +{ ?Unknown?, ?DVI-D?, ?DVI-A? } +Connector +TBD + + +?select subconnector? +ENUM +{ ?Automatic?, ?DVI-D?, ?DVI-A? } +Connector +TBD + + +TV +?subconnector? +ENUM +{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" } +Connector +TBD + + +?select subconnector? +ENUM +{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" } +Connector +TBD + + +?mode? +ENUM +{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. +Connector +TBD + + +?left margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?right margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?top margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?bottom margin? +RANGE +Min=0, Max=100 +Connector +TBD + + +?brightness? +RANGE +Min=0, Max=100 +Connector +TBD + + +?contrast? +RANGE +Min=0, Max=100 +Connector +TBD + + +?flicker reduction? +RANGE +Min=0, Max=100 +Connector +TBD + + +?overscan? +RANGE +Min=0, Max=100 +Connector +TBD + + +?saturation? +RANGE +Min=0, Max=100 +Connector +TBD + + +?hue? +RANGE +Min=0, Max=100 +Connector +TBD + + +Optional +?scaling mode? +ENUM +{ "None", "Full", "Center", "Full aspect" } +Connector +TBD + + +?dirty? +ENUM | IMMUTABLE +{ "Off", "On", "Annotate" } +Connector +TBD + + +i915 +Generic +"Broadcast RGB" +ENUM +{ "Automatic", "Full", "Limited 16:235" } +Connector +TBD + + +?audio? +ENUM +{ "force-dvi", "off", "auto", "on" } +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + +SDVO-TV +?mode? +ENUM +{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. +Connector +TBD + + +"left_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"right_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"top_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +"bottom_margin" +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?vpos? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?contrast? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?saturation? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?hue? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?sharpness? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter_adaptive? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?flicker_filter_2d? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?tv_chroma_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?tv_luma_filter? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +?dot_crawl? +RANGE +Min=0, Max=1 +Connector +TBD + + +SDVO-TV/LVDS +?brightness? +RANGE +Min=0, Max= SDVO dependent +Connector +TBD + + +CDV gma-500 +Generic +"Broadcast RGB" +ENUM +{ ?Full?, ?Limited 16:235? } +Connector +TBD + + +"Broadcast RGB" +ENUM +{ ?off?, ?auto?, ?on? } +Connector +TBD + + +Standard name as in DRM +Standard type as in DRM +Standard value as in DRM +Standard Object as in DRM +TBD + + +Poulsbo +Generic +?backlight? +RANGE +Min=0, Max
[PATCH v7 1/1] Documentation: drm: describing drm properties exposed by various drivers
From: Sagar Kamble Started documenting drm properties for drm drivers. This patch provides information about properties in drm, i915, psb and cdv/gma-500. Information about other properties can be added on top of these. v2: Added description of drm properties in armada, exynos, i2c/ch7006, noveau, omap, qxl, radeon, rcar-du v3: Removed "Property Object" column since it is implementation related. Property type column refined.[Ville's review comments] v4: Removed whitespace warnings and minor nits. [Randy's review comments] v5: Restructured output for ENUM properties v6: Review comments on formatting the table. [Laurent's review comments] v7: Minor restructuring. [Laurent's review comments] Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 849 + 1 file changed, 849 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index ed1d6d2..104402a 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2317,6 +2317,855 @@ void intel_crt_init(struct drm_device *dev) pointer to the target object, a pointer to the previously created property and an initial instance value. + + Existing KMS Properties + + The following table gives description of drm properties exposed by various + modules/drivers. + + + + + Owner Module/Drivers + Group + Property Name + Type + Property Values + Object attached + Description/Restrictions + + + DRM + Generic + ?EDID? + BLOB | IMMUTABLE + 0 + Connector + Contains id of edid blob ptr object. + + + ?DPMS? + ENUM + { ?On?, ?Standby?, ?Suspend?, ?Off? } + Connector + Contains DPMS operation mode value. + + + DVI-I + ?subconnector? + ENUM + { ?Unknown?, ?DVI-D?, ?DVI-A? } + Connector + TBD + + + ?select subconnector? + ENUM + { ?Automatic?, ?DVI-D?, ?DVI-A? } + Connector + TBD + + + TV + ?subconnector? + ENUM + { "Unknown", "Composite", "SVIDEO", "Component", "SCART" } + Connector + TBD + + + ?select subconnector? + ENUM + { "Automatic", "Composite", "SVIDEO", "Component", "SCART" } + Connector + TBD + + + ?mode? + ENUM + { "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. + Connector + TBD + + + ?left margin? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?right margin? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?top margin? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?bottom margin? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?brightness? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?contrast? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?flicker reduction? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?overscan? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?saturation? + RANGE + Min=0, Max=100 + Connector + TBD + + + ?hue? + RANGE + Min=0, Max=100 + Connector + TBD + + + Optional + ?scaling mode? + ENUM + { "None", "Full", "Center", "Full aspect" } + Connector + TBD + + + ?dirty? + ENUM | IMMUTABLE + { "Off", "On", "Annotate" } + Connector + TBD + + + i915 + Generic + "Broadcast RGB" + ENUM + { "Automatic", "Full", "Limited 16:235" } + Connector + TBD + + + ?audio? + ENUM + { "force-dvi", "off", "auto", "on" } + Connector + TBD + + + Standard name as in DRM + Standard type as in DRM + Standard value as in DRM + Standard Object as in DRM + TBD + + + SDVO-TV + ?mode? + ENUM + { "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc. + Connector + TBD + + + "left_margin" + RANGE + Min=0, Max= SDVO dependent + Connector + TBD + + + "right_margin" + RANGE + M
[PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair
From: Sagar Kamble With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use of 64 bit value of bitmask property as two 32 bit values. Cc: airlied at linux.ie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 22 -- include/uapi/drm/drm_mode.h | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4e43fc2..d0d03ec 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index, /* * Bitmask enum properties have the additional constraint of values -* from 0 to 63 +* from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint +* range is 0 to 31. */ - if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63)) - return -EINVAL; + if (property->flags & DRM_MODE_PROP_BITMASK) + if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) || + (value > 63)) + return -EINVAL; if (!list_empty(&property->enum_blob_list)) { list_for_each_entry(prop_enum, &property->enum_blob_list, head) { @@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property, } else if (property->flags & DRM_MODE_PROP_BITMASK) { int i; uint64_t valid_mask = 0; - for (i = 0; i < property->num_values; i++) - valid_mask |= (1ULL << property->values[i]); - return !(value & ~valid_mask); + uint32_t valid_32bit_mask = 0; + if (property->flags & DRM_MODE_PROP_32BIT_PAIR) { + for (i = 0; i < property->num_values; i++) + valid_32bit_mask |= (1UL << property->values[i]); + return !((value & 0x) & ~valid_32bit_mask); + } else { + for (i = 0; i < property->num_values; i++) + valid_mask |= (1ULL << property->values[i]); + return !(value & ~valid_mask); + } } else if (property->flags & DRM_MODE_PROP_BLOB) { /* Only the driver knows */ return true; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index f104c26..5e3a7d9 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -250,6 +250,9 @@ struct drm_mode_get_connector { #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */ #define DRM_MODE_PROP_BLOB (1<<4) #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */ +#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types +* and 32 bit of value of the type */ + struct drm_mode_property_enum { __u64 value; -- 1.8.5
[PATCH v2 2/4] drm: Added plane alpha and color blending property
From: Sagar Kamble This patch creates a generic blending bitmask property modeled after glBlendFunc. Drivers may support subset of these values. v2: Removing blend properties that are not applicable [Damien's Review Comments]. Adding DRM_MODE_PROP_32BIT_PAIR flag to blend property. Cc: airlied at linux.ie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 27 +++ include/drm/drm_crtc.h | 19 +++ 2 files changed, 46 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d0d03ec..a1f254e 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4157,3 +4157,30 @@ void drm_mode_config_cleanup(struct drm_device *dev) idr_destroy(&dev->mode_config.crtc_idr); } EXPORT_SYMBOL(drm_mode_config_cleanup); + +struct drm_property *drm_mode_create_blend_property(struct drm_device *dev, + unsigned int supported_factors) +{ + static const struct drm_prop_enum_list props[] = { + { DRM_BLEND_ZERO, "zero" }, + { DRM_BLEND_ONE,"one" }, + { DRM_BLEND_SRC_COLOR, "src-color" }, + { DRM_BLEND_ONE_MINUS_SRC_COLOR,"one-minus-src-color" }, + { DRM_BLEND_DST_COLOR, "dst-color" }, + { DRM_BLEND_ONE_MINUS_DST_COLOR,"one-minus-dst-color" }, + { DRM_BLEND_SRC_ALPHA, "src-alpha" }, + { DRM_BLEND_ONE_MINUS_SRC_ALPHA,"one-minus-src-alpha" }, + { DRM_BLEND_DST_ALPHA, "dst-alpha" }, + { DRM_BLEND_ONE_MINUS_DST_ALPHA,"one-minus-dst-alpha" }, + { DRM_BLEND_CONSTANT_COLOR, "constant-color" }, + { DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, "one-minus-constant-color" }, + { DRM_BLEND_CONSTANT_ALPHA, "constant-alpha" }, + { DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, "one-minus-constant-alpha" }, + { DRM_BLEND_SRC_ALPHA_SATURATE, "alpha-saturate" } + }; + + return drm_property_create_bitmask(dev, DRM_MODE_PROP_32BIT_PAIR, "blend", + props, ARRAY_SIZE(props), + supported_factors); +} +EXPORT_SYMBOL(drm_mode_create_blend_property); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 784a568..a9fbfec 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -65,6 +65,23 @@ struct drm_object_properties { uint64_t values[DRM_OBJECT_MAX_PROPERTY]; }; +/* Blending property bits */ +#define DRM_BLEND_ZERO 0 +#define DRM_BLEND_ONE 1 +#define DRM_BLEND_SRC_COLOR2 +#define DRM_BLEND_ONE_MINUS_SRC_COLOR 3 +#define DRM_BLEND_DST_COLOR4 +#define DRM_BLEND_ONE_MINUS_DST_COLOR 5 +#define DRM_BLEND_SRC_ALPHA6 +#define DRM_BLEND_ONE_MINUS_SRC_ALPHA 7 +#define DRM_BLEND_DST_ALPHA8 +#define DRM_BLEND_ONE_MINUS_DST_ALPHA 9 +#define DRM_BLEND_CONSTANT_COLOR 10 +#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR 11 +#define DRM_BLEND_CONSTANT_ALPHA 12 +#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA 13 +#define DRM_BLEND_SRC_ALPHA_SATURATE 14 + /* * Note on terminology: here, for brevity and convenience, we refer to connector * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, @@ -1179,6 +1196,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane); extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); +extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev, + unsigned int supported_factors); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property
From: Sagar Kamble v2: Added description for "src-color" and "constant-alpha" property. Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 104402a..77a45fb 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev) enumerated bits defined by the property. + DRM_MODE_PROP_32BIT_PAIR + This flag restricts Bitmask properties restricts all + enumerated values to the 0..31 range. +During get operation instance values combine one or more of the +enumerated bits defined by the property. During get user can specify + {type, value} pair. + + DRM_MODE_PROP_BLOB Blob properties store a binary blob without any format restriction. The binary blobs are created as KMS standalone objects, @@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev) DRM - Generic + Generic ?EDID? BLOB | IMMUTABLE 0 @@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + ?blend? + BITMASK | 32BIT_PAIR + { {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"} + , {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"} + , {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"} + , {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} } + Plane + Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API + in OpenGL. Currently only "src-color" and "constant-alpha" are supported. "src-color" will consider supplied fb + with plane's pixel format as input without any additional color/alpha changes."constant-alpha" will apply constant + transparency to all pixels in addition to source color. + + DVI-I ?subconnector? ENUM -- 1.8.5
[PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property
From: Sagar Kamble v2: Added description for "src-color" and "constant-alpha" property. [Review by Laurent Pinchart] v3: Fixed typos. [Review by David Hermann] Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 104402a..66386d0 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev) enumerated bits defined by the property. + DRM_MODE_PROP_32BIT_PAIR + This flag restricts all enumerated values of Bitmask properties + to the 0..31 range. +'get_property' operation will get combination of instance values of one or more of the +enumerated bits defined by the property. With 'set_property' operation, user can specify + {value (MSB 32 bits), type (LSB 32 bits)} pair with 64 bit value for that property. + + DRM_MODE_PROP_BLOB Blob properties store a binary blob without any format restriction. The binary blobs are created as KMS standalone objects, @@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev) DRM - Generic + Generic ?EDID? BLOB | IMMUTABLE 0 @@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + ?blend? + BITMASK | 32BIT_PAIR + { {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"} + , {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"} + , {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"} + , {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} } + Plane + Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API + in OpenGL. Currently only "src-color" and "constant-alpha" are supported. "src-color" will consider supplied fb + with plane's pixel format as input without any additional color/alpha changes."constant-alpha" will apply constant + transparency to all pixels in addition to source color. + + DVI-I ?subconnector? ENUM -- 1.8.5
[PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property
From: Sagar Kamble v2: Added description for "src-color" and "constant-alpha" property. [Review by Laurent Pinchart] v3: Fixed typos. [Review by David Herrmann] Cc: Rob Landley Cc: Dave Airlie Cc: Daniel Vetter Cc: Laurent Pinchart Cc: David Herrmann Cc: Alex Deucher Cc: "Ville Syrj?l?" Cc: Sagar Kamble Cc: "Purushothaman, Vijay A" Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 104402a..66386d0 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev) enumerated bits defined by the property. + DRM_MODE_PROP_32BIT_PAIR + This flag restricts all enumerated values of Bitmask properties + to the 0..31 range. +'get_property' operation will get combination of instance values of one or more of the +enumerated bits defined by the property. With 'set_property' operation, user can specify + {value (MSB 32 bits), type (LSB 32 bits)} pair with 64 bit value for that property. + + DRM_MODE_PROP_BLOB Blob properties store a binary blob without any format restriction. The binary blobs are created as KMS standalone objects, @@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev) DRM - Generic + Generic ?EDID? BLOB | IMMUTABLE 0 @@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + ?blend? + BITMASK | 32BIT_PAIR + { {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"} + , {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"} + , {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"} + , {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} } + Plane + Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API + in OpenGL. Currently only "src-color" and "constant-alpha" are supported. "src-color" will consider supplied fb + with plane's pixel format as input without any additional color/alpha changes."constant-alpha" will apply constant + transparency to all pixels in addition to source color. + + DVI-I ?subconnector? ENUM -- 1.8.5
[PATCH v4 1/1] Documentation: drm: describing plane alpha and color blending property
From: Sagar Kamble v2: Added description for "src-color" and "constant-alpha" property. [Review by Laurent Pinchart] v3: Fixed typos. [Review by David Herrmann] v4: Additional formatting and modified description. [Review by David Herrmann] Cc: rob at landley.net Cc: airlied at redhat.com Cc: daniel.vetter at ffwll.ch Cc: laurent.pinchart at ideasonboard.com Cc: dh.herrmann at gmail.com Cc: alexander.deucher at amd.com Cc: ville.syrjala at linux.intel.com Cc: sagar.a.kamble at intel.com Cc: vijay.a.purushothaman at intel.com Cc: linux-doc at vger.kernel.org Cc: dri-devel at lists.freedesktop.org Signed-off-by: Sagar Kamble --- Documentation/DocBook/drm.tmpl | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 104402a..dd2ae67 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2264,6 +2264,20 @@ void intel_crt_init(struct drm_device *dev) + In addition to above types, properties can be constrained by supplying additional + flags while creating the property. Supported flags are + + + DRM_MODE_PROP_32BIT_PAIR + This flag is applicable to Bitmask enum properties. It creates + Pair-properties that store two packed 32 bit values as 64bit unsigned integer + (often used as key-value pair). The lower 32 bits contain the first value (also: key), + while the upper 32 bits contain the second value. + Written as: ({key (LSB 32 bits), value (MSB 32 bits)}). + + + + To create a property drivers call one of the following functions depending on the property type. All property creation functions take property flags and name, as well as type-specific arguments. @@ -2336,7 +2350,7 @@ void intel_crt_init(struct drm_device *dev) DRM - Generic + Generic ???EDID??? BLOB | IMMUTABLE 0 @@ -2351,6 +2365,22 @@ void intel_crt_init(struct drm_device *dev) Contains DPMS operation mode value. + ???blend??? + BITMASK | 32BIT_PAIR + { "zero" = 0, "one" = 1, "src-color" = 2, "one-minus-src-color" = 3 + , "dst-color" = 4, "one-minus-dst-color" = 5, "src-alpha"= 6, "one-minus-src-alpha" = 7, "dst-alpha" = 8 + , "one-minus-dst-alpha" = 9, "constant-color" = 10, "one-minus-constant-color" = 11, "constant-alpha" = 12 + , "one-minus-constant-alpha" = 13, "alpha-saturate" = 14 } + Plane + Contains plane alpha/color blending operation values. These are modeled after the glBlendFunc API + in OpenGL. Not all modes are supported by all drivers. The first value of the 32BIT_PAIR describes the blending mode + of the source plane, the second value describes the blending factors of the source plane. + + For e.g. to apply constant alpha of 0xFF on source plane, the first value of this property for source plane should + be set to 2^10 and second value to value of alpha(0xFF). + + + DVI-I ???subconnector??? ENUM -- 1.8.5
[PATCH v4 07/11] drm/i915: Add 180 degree sprite rotation support
From: Ville Syrj?l? The sprite planes (in fact all display planes starting from gen4) support 180 degree rotation. Add the relevant low level bits to the sprite code to make use of that feature. The upper layers are not yet plugged in. v2: HSW handles the rotated buffer offset automagically Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_drv.h| 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 + 3 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index abd18cd..57906c5 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3637,6 +3637,7 @@ #define DVS_YUV_ORDER_UYVY (1<<16) #define DVS_YUV_ORDER_YVYU (2<<16) #define DVS_YUV_ORDER_VYUY (3<<16) +#define DVS_ROTATE_180 (1<<15) #define DVS_DEST_KEY (1<<2) #define DVS_TRICKLE_FEED_DISABLE (1<<14) #define DVS_TILED(1<<10) @@ -3707,6 +3708,7 @@ #define SPRITE_YUV_ORDER_UYVY(1<<16) #define SPRITE_YUV_ORDER_YVYU(2<<16) #define SPRITE_YUV_ORDER_VYUY(3<<16) +#define SPRITE_ROTATE_180(1<<15) #define SPRITE_TRICKLE_FEED_DISABLE (1<<14) #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) @@ -3780,6 +3782,7 @@ #define SP_YUV_ORDER_UYVY(1<<16) #define SP_YUV_ORDER_YVYU(2<<16) #define SP_YUV_ORDER_VYUY(3<<16) +#define SP_ROTATE_180(1<<15) #define SP_TILED (1<<10) #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184) #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bc..85864fc 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -397,6 +397,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + unsigned int rotation; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 336ae6c..477d4d7 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -60,6 +60,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, sprctl &= ~SP_PIXFORMAT_MASK; sprctl &= ~SP_YUV_BYTE_ORDER_MASK; sprctl &= ~SP_TILED; + sprctl &= ~SP_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_YUYV: @@ -131,6 +132,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SP_ROTATE_180; + + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); @@ -238,6 +247,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, sprctl &= ~SPRITE_RGB_ORDER_RGBX; sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; sprctl &= ~SPRITE_TILED; + sprctl &= ~SPRITE_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -299,6 +309,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SPRITE_ROTATE_180; + + /* HSW does this automagically in hardware */ + if (!IS_HASWELL(dev)) { + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + } + I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); @@ -422,6 +443,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, dvscntr &= ~DVS_RGB_ORDER_XBGR; dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; dvscntr &= ~DVS_TILED; + dvscntr &= ~DVS_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -478,6 +500,14 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= dvssurf_offset; + if (intel_plane->rotation == BIT(DRM_ROT
[PATCH v4 00/11] Enabling 180 degree rotation for sprite and crtc planes
From: Sagar Kamble These patches will enable 180 degree rotation for CRTC and Sprite planes. Changelog: 1. drm/i915: Add 180 degree primary plane rotation support Addressed review comments for CRTC rotation from FBC, page flip, CRTC active/ inactive perspective. 2. drm/i915: Calling rotate and inverse rotate transformations after clipping Moved drm_rect_rotate below clip operation in intel_update_plane. Added rotate and inverse rotate transforms for dest rect as well. 3. drm: Add drm_mode_create_rotation_property() Fixed bug in drm_mode_create_rotation_property to create entries only for supported rotations. Sagar Kamble (2): drm/i915: Add 180 degree primary plane rotation support drm/i915: Calling rotate and inverse rotate transformations after clipping Ville Syrj?l? (9): drm: Move DRM_ROTATE bits out of omapdrm into drm_crtc.h drm: Add support_bits parameter to drm_property_create_bitmask() drm: Add drm_mode_create_rotation_property() drm/omap: Switch omapdrm over to drm_mode_create_rotation_property() drm: Add drm_rect rotation functions drm: Add drm_rotation_simplify() drm/i915: Add 180 degree sprite rotation support drm/i915: Make intel_plane_restore() return an error drm/i915: Add rotation property for sprites drivers/gpu/drm/drm_crtc.c | 69 - drivers/gpu/drm/drm_rect.c | 140 +++ drivers/gpu/drm/i915/i915_dma.c | 12 +++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 4 + drivers/gpu/drm/i915/intel_display.c | 86 - drivers/gpu/drm/i915/intel_drv.h | 5 +- drivers/gpu/drm/i915/intel_pm.c | 9 +++ drivers/gpu/drm/i915/intel_sprite.c | 101 +++-- drivers/gpu/drm/omapdrm/omap_drv.h | 7 -- drivers/gpu/drm/omapdrm/omap_plane.c | 17 ++--- include/drm/drm_crtc.h | 15 +++- include/drm/drm_rect.h | 6 ++ 13 files changed, 440 insertions(+), 32 deletions(-) -- 1.8.5
[PATCH v4 01/11] drm: Move DRM_ROTATE bits out of omapdrm into drm_crtc.h
From: Ville Syrj?l? The rotation property stuff should be standardized among all drivers. Move the bits to drm_crtc.h from omap_drv.h. Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/omapdrm/omap_drv.h | 7 --- include/drm/drm_crtc.h | 8 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 428b2981..aac8e10 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -119,13 +119,6 @@ struct omap_drm_private { struct omap_drm_irq error_handler; }; -/* this should probably be in drm-core to standardize amongst drivers */ -#define DRM_ROTATE_0 0 -#define DRM_ROTATE_90 1 -#define DRM_ROTATE_180 2 -#define DRM_ROTATE_270 3 -#define DRM_REFLECT_X 4 -#define DRM_REFLECT_Y 5 #ifdef CONFIG_DEBUG_FS int omap_debugfs_init(struct drm_minor *minor); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 71727b6..d5c46c1 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -65,6 +65,14 @@ struct drm_object_properties { uint64_t values[DRM_OBJECT_MAX_PROPERTY]; }; +/* rotation property bits */ +#define DRM_ROTATE_0 0 +#define DRM_ROTATE_90 1 +#define DRM_ROTATE_180 2 +#define DRM_ROTATE_270 3 +#define DRM_REFLECT_X 4 +#define DRM_REFLECT_Y 5 + /* * Note on terminology: here, for brevity and convenience, we refer to connector * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, -- 1.8.5
[PATCH v4 02/11] drm: Add support_bits parameter to drm_property_create_bitmask()
From: Ville Syrj?l? Make drm_property_create_bitmask() a bit more generic by allowing the caller to specify which bits are in fact supported. This allows multiple callers to use the same enum list, but still create different versions of the same property with different list of supported bits. Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 6 +- include/drm/drm_crtc.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 3b7d32d..628d3d3 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2906,7 +2906,8 @@ EXPORT_SYMBOL(drm_property_create_enum); struct drm_property *drm_property_create_bitmask(struct drm_device *dev, int flags, const char *name, const struct drm_prop_enum_list *props, -int num_values) +int num_values, +unsigned int supported_bits) { struct drm_property *property; int i, ret; @@ -2918,6 +2919,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, return NULL; for (i = 0; i < num_values; i++) { + if (!(supported_bits & (1 << i))) + continue; + ret = drm_property_add_enum(property, i, props[i].type, props[i].name); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index d5c46c1..41b86d2 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1070,7 +1070,8 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int struct drm_property *drm_property_create_bitmask(struct drm_device *dev, int flags, const char *name, const struct drm_prop_enum_list *props, -int num_values); +int num_values, +unsigned int supported_bits); struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, const char *name, uint64_t min, uint64_t max); -- 1.8.5
[PATCH v4 03/11] drm: Add drm_mode_create_rotation_property()
From: Ville Syrj?l? Add a function to create a standards compliant rotation property. v4: For creating rotation bitmask property send number of values as only number of set rotations Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 33 + include/drm/drm_crtc.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 628d3d3..e7bbbad 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4118,3 +4118,36 @@ void drm_mode_config_cleanup(struct drm_device *dev) idr_destroy(&dev->mode_config.crtc_idr); } EXPORT_SYMBOL(drm_mode_config_cleanup); + +/* +* Function to get number of bits set in bitmask +* using Brian Kernighan's Algorithm +*/ +unsigned int bits_set(unsigned int n) +{ + unsigned int count = 0; + + while (n) { + n &= (n-1); + count ++; + } + return count; +} + +struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, + unsigned int supported_rotations) +{ + static const struct drm_prop_enum_list props[] = { + { DRM_ROTATE_0, "rotate-0" }, + { DRM_ROTATE_90, "rotate-90" }, + { DRM_ROTATE_180, "rotate-180" }, + { DRM_ROTATE_270, "rotate-270" }, + { DRM_REFLECT_X, "reflect-x" }, + { DRM_REFLECT_Y, "reflect-y" }, + }; + + return drm_property_create_bitmask(dev, 0, "rotation", + props, bits_set(supported_rotations), + supported_rotations); +} +EXPORT_SYMBOL(drm_mode_create_rotation_property); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 41b86d2..4b3ac70 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1183,6 +1183,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane); extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); +extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, + unsigned int supported_rotations); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH v4 04/11] drm/omap: Switch omapdrm over to drm_mode_create_rotation_property()
From: Ville Syrj?l? Use the new drm_mode_create_rotation_property() in omapdrm. Signed-off-by: Ville Syrj?l? --- drivers/gpu/drm/omapdrm/omap_plane.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 046d5e6..fee8f35 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -300,16 +300,13 @@ void omap_plane_install_properties(struct drm_plane *plane, if (priv->has_dmm) { prop = priv->rotation_prop; if (!prop) { - const struct drm_prop_enum_list props[] = { - { DRM_ROTATE_0, "rotate-0" }, - { DRM_ROTATE_90, "rotate-90" }, - { DRM_ROTATE_180, "rotate-180" }, - { DRM_ROTATE_270, "rotate-270" }, - { DRM_REFLECT_X, "reflect-x" }, - { DRM_REFLECT_Y, "reflect-y" }, - }; - prop = drm_property_create_bitmask(dev, 0, "rotation", - props, ARRAY_SIZE(props)); + prop = drm_mode_create_rotation_property(dev, + BIT(DRM_ROTATE_0) | + BIT(DRM_ROTATE_90) | + BIT(DRM_ROTATE_180) | + BIT(DRM_ROTATE_270) | + BIT(DRM_REFLECT_X) | + BIT(DRM_REFLECT_Y)); if (prop == NULL) return; priv->rotation_prop = prop; -- 1.8.5
[PATCH v4 05/11] drm: Add drm_rect rotation functions
From: Ville Syrj?l? Add some helper functions to move drm_rects between different rotated coordinate spaces. One function does the forward transform and another does the inverse. Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/drm_rect.c | 140 + include/drm/drm_rect.h | 6 ++ 2 files changed, 146 insertions(+) diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c index 7047ca0..631f5af 100644 --- a/drivers/gpu/drm/drm_rect.c +++ b/drivers/gpu/drm/drm_rect.c @@ -293,3 +293,143 @@ void drm_rect_debug_print(const struct drm_rect *r, bool fixed_point) DRM_DEBUG_KMS("%dx%d%+d%+d\n", w, h, r->x1, r->y1); } EXPORT_SYMBOL(drm_rect_debug_print); + +/** + * drm_rect_rotate - Rotate the rectangle + * @r: rectangle to be rotated + * @width: Width of the coordinate space + * @height: Height of the coordinate space + * @rotation: Transformation to be applied + * + * Apply @rotation to the coordinates of rectangle @r. + * + * @width and @height combined with @rotation define + * the location of the new origin. + * + * @width correcsponds to the horizontal and @height + * to the vertical axis of the untransformed coordinate + * space. + */ +void drm_rect_rotate(struct drm_rect *r, +int width, int height, +unsigned int rotation) +{ + struct drm_rect tmp; + + if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { + tmp = *r; + + if (rotation & BIT(DRM_REFLECT_X)) { + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + } + + if (rotation & BIT(DRM_REFLECT_Y)) { + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + } + } + + switch (rotation & 0xf) { + case BIT(DRM_ROTATE_0): + break; + case BIT(DRM_ROTATE_90): + tmp = *r; + r->x1 = tmp.y1; + r->x2 = tmp.y2; + r->y1 = width - tmp.x2; + r->y2 = width - tmp.x1; + break; + case BIT(DRM_ROTATE_180): + tmp = *r; + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + break; + case BIT(DRM_ROTATE_270): + tmp = *r; + r->x1 = height - tmp.y2; + r->x2 = height - tmp.y1; + r->y1 = tmp.x1; + r->y2 = tmp.x2; + break; + default: + break; + } +} +EXPORT_SYMBOL(drm_rect_rotate); + +/** + * drm_rect_rotate_inv - Inverse rotate the rectangle + * @r: rectangle to be rotated + * @width: Width of the coordinate space + * @height: Height of the coordinate space + * @rotation: Transformation whose inverse is to be applied + * + * Apply the inverse of @rotation to the coordinates + * of rectangle @r. + * + * @width and @height combined with @rotation define + * the location of the new origin. + * + * @width correcsponds to the horizontal and @height + * to the vertical axis of the original untransformed + * coordinate space, so that you never have to flip + * them when doing a rotatation and its inverse. + * That is, if you do: + * + * drm_rotate(&r, width, height, rotation); + * drm_rotate_inv(&r, width, height, rotation); + * + * you will always get back the original rectangle. + */ +void drm_rect_rotate_inv(struct drm_rect *r, +int width, int height, +unsigned int rotation) +{ + struct drm_rect tmp; + + switch (rotation & 0xf) { + case BIT(DRM_ROTATE_0): + break; + case BIT(DRM_ROTATE_90): + tmp = *r; + r->x1 = width - tmp.y2; + r->x2 = width - tmp.y1; + r->y1 = tmp.x1; + r->y2 = tmp.x2; + break; + case BIT(DRM_ROTATE_180): + tmp = *r; + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + break; + case BIT(DRM_ROTATE_270): + tmp = *r; + r->x1 = tmp.y1; + r->x2 = tmp.y2; + r->y1 = height - tmp.x2; + r->y2 = height - tmp.x1; + break; + default: + break; + } + + if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { + tmp = *r; + + if (rotation & BIT(DRM_REFLECT_X)) { + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + } + + if (rotation & BIT(DRM_REFLECT_Y)) { + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; +
[PATCH v4 06/11] drm: Add drm_rotation_simplify()
From: Ville Syrj?l? drm_rotation_simplify() can be used to eliminate unsupported rotation flags. It will check if any unsupported flags are present, and if so it will modify the rotation to an alternate form by adding 180 degrees to rotation angle, and flipping the reflect x and y bits. The hope is that this identity transform will eliminate the unsupported flags. Of course that might not result in any more supported rotation, so the caller is still responsible for checking the result afterwards. Signed-off-by: Ville Syrj?l? --- drivers/gpu/drm/drm_crtc.c | 30 ++ include/drm/drm_crtc.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index e7bbbad..30e0008 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4006,6 +4006,36 @@ int drm_format_vert_chroma_subsampling(uint32_t format) EXPORT_SYMBOL(drm_format_vert_chroma_subsampling); /** + * drm_rotation_simplify() - Try to simplify the rotation + * @rotation: Rotation to be simplified + * @supported_rotations: Supported rotations + * + * Attempt to simplify the rotation to a form that is supported. + * Eg. if the hardware supports everything except DRM_REFLECT_X + * one could call this function like this: + * + * drm_rotation_simplify(rotation, BIT(DRM_ROTATE_0) | + * BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_180) | + * BIT(DRM_ROTATE_270) | BIT(DRM_REFLECT_Y)); + * + * to eliminate the DRM_ROTATE_X flag. Depending on what kind of + * transforms the hardware supports, this function may not + * be able to produce a supported transform, so the caller should + * check the result afterwards. + */ +unsigned int drm_rotation_simplify(unsigned int rotation, + unsigned int supported_rotations) +{ + if (rotation & ~supported_rotations) { + rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y); + rotation = (rotation & ~0xf) | BIT((ffs(rotation & 0xf) + 1) % 4); + } + + return rotation; +} +EXPORT_SYMBOL(drm_rotation_simplify); + +/** * drm_mode_config_init - initialize DRM mode_configuration structure * @dev: DRM device * diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 4b3ac70..18f2eed 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1185,6 +1185,8 @@ extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, unsigned int supported_rotations); +extern unsigned int drm_rotation_simplify(unsigned int rotation, + unsigned int supported_rotations); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH v4 09/11] drm/i915: Add rotation property for sprites
From: Ville Syrj?l? Sprite planes support 180 degree rotation. The lower layers are now in place, so hook in the standard rotation property to expose the feature to the users. Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 42 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index fa37dfd..ea2efc3 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1548,6 +1548,7 @@ typedef struct drm_i915_private { struct drm_property *broadcast_rgb_property; struct drm_property *force_audio_property; + struct drm_property *rotation_property; uint32_t hw_context_size; struct list_head context_list; diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 511934c..62b9f84 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1047,6 +1047,30 @@ out_unlock: return ret; } +static int intel_plane_set_property(struct drm_plane *plane, + struct drm_property *prop, + uint64_t val) +{ + struct drm_i915_private *dev_priv = plane->dev->dev_private; + struct intel_plane *intel_plane = to_intel_plane(plane); + uint64_t old_val; + int ret = -ENOENT; + + if (prop == dev_priv->rotation_property) { + /* exactly one rotation angle please */ + if (hweight32(val & 0xf) != 1) + return -EINVAL; + + old_val = intel_plane->rotation; + intel_plane->rotation = val; + ret = intel_plane_restore(plane); + if (ret) + intel_plane->rotation = old_val; + } + + return ret; +} + int intel_plane_restore(struct drm_plane *plane) { struct intel_plane *intel_plane = to_intel_plane(plane); @@ -1073,6 +1097,7 @@ static const struct drm_plane_funcs intel_plane_funcs = { .update_plane = intel_update_plane, .disable_plane = intel_disable_plane, .destroy = intel_destroy_plane, + .set_property = intel_plane_set_property, }; static uint32_t ilk_plane_formats[] = { @@ -1109,6 +1134,7 @@ static uint32_t vlv_plane_formats[] = { int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) { + struct drm_i915_private *dev_priv = dev->dev_private; struct intel_plane *intel_plane; unsigned long possible_crtcs; const uint32_t *plane_formats; @@ -1183,8 +1209,22 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) &intel_plane_funcs, plane_formats, num_plane_formats, false); - if (ret) + if (ret) { kfree(intel_plane); + goto out; + } + + if (!dev_priv->rotation_property) + dev_priv->rotation_property = + drm_mode_create_rotation_property(dev, + BIT(DRM_ROTATE_0) | + BIT(DRM_ROTATE_180)); + + if (dev_priv->rotation_property) + drm_object_attach_property(&intel_plane->base.base, + dev_priv->rotation_property, + intel_plane->rotation); + out: return ret; } -- 1.8.5
[PATCH v4 10/11] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. Signed-off-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 12 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 86 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 9 5 files changed, 106 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..fcd9e34 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct drm_crtc *crtc; + struct drm_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,16 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) + drm_object_property_set_value(&crtc->base, + dev_priv->rotation_property, 0); + + list_for_each_entry(plane, &dev->mode_config.plane_list, head) + drm_object_property_set_value(&plane->base, + dev_priv->rotation_property, 0); + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..4a4f650 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, dspcntr = I915_READ(reg); /* Mask out pixel format bits in case we change it */ dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; + dspcntr &= ~DISPPLANE_ROTATE_180; + switch (fb->pixel_format) { case DRM_FORMAT_C8: dspcntr |= DISPPLANE_8BPP; @@ -2095,8 +2099,6 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, if (IS_G4X(dev)) dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; - I915_WRITE(reg, dspcntr); - linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); if (INTEL_INFO(dev)->gen >= 4) { @@ -2109,6 +2111,17 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, intel_crtc->dspaddr_offset = linear_offset; } + if (intel_crtc->rotation == BIT(DRM_ROTATE_180)) { + dspcntr |= DISPPLANE_ROTATE_180; + + x += (intel_crtc->config.pipe_src_w - 1); + y += (intel_crtc->config.pipe_src_h - 1); + linear_offset += (intel_crtc->config.pipe_src_h - 1) * fb->pitches[0] + + intel_crtc->
[PATCH v4 11/11] drm/i915: Calling rotate and inverse rotate transformations after clipping
From: Sagar Kamble With clipped sprites these transformations are not working. these functions transform complete sprite irrespective of clipping present. This leads to invisible portion of sprite show up when rotate 180 if it was out of visible area before. v4: Moved rotate transform for source rectangle after clipping. Added rotate and inverse rotate transform for destination rect. Signed-off-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/intel_sprite.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 62b9f84..799f6a9 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -769,9 +769,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, max_scale = intel_plane->max_downscale << 16; min_scale = intel_plane->can_scale ? 1 : (1 << 16); - drm_rect_rotate(&src, fb->width << 16, fb->height << 16, - intel_plane->rotation); - hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale); BUG_ON(hscale < 0); @@ -785,6 +782,13 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, crtc_w = drm_rect_width(&dst); crtc_h = drm_rect_height(&dst); + drm_rect_rotate(&src, fb->width << 16, fb->height << 16, + intel_plane->rotation); + + drm_rect_rotate(&dst, intel_crtc->config.pipe_src_w, + intel_crtc->config.pipe_src_h, + intel_plane->rotation); + if (visible) { /* check again in case clipping clamped the results */ hscale = drm_rect_calc_hscale(&src, &dst, min_scale, max_scale); @@ -811,7 +815,11 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, drm_rect_height(&dst) * vscale - drm_rect_height(&src)); drm_rect_rotate_inv(&src, fb->width << 16, fb->height << 16, - intel_plane->rotation); + intel_plane->rotation); + + drm_rect_rotate_inv(&dst, intel_crtc->config.pipe_src_w, + intel_crtc->config.pipe_src_h, + intel_plane->rotation); /* sanity check to make sure the src viewport wasn't enlarged */ WARN_ON(src.x1 < (int) src_x || -- 1.8.5
[PATCH v4 08/11] drm/i915: Make intel_plane_restore() return an error
From: Ville Syrj?l? Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller. This will be used for rollback purposes when setting properties fails. Signed-off-by: Ville Syrj?l? Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/intel_drv.h| 2 +- drivers/gpu/drm/i915/intel_sprite.c | 14 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 85864fc..7a79b8e 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -897,7 +897,7 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob); int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane); void intel_flush_primary_plane(struct drm_i915_private *dev_priv, enum plane plane); -void intel_plane_restore(struct drm_plane *plane); +int intel_plane_restore(struct drm_plane *plane); void intel_plane_disable(struct drm_plane *plane); int intel_sprite_set_colorkey(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 477d4d7..511934c 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1047,18 +1047,18 @@ out_unlock: return ret; } -void intel_plane_restore(struct drm_plane *plane) +int intel_plane_restore(struct drm_plane *plane) { struct intel_plane *intel_plane = to_intel_plane(plane); if (!plane->crtc || !plane->fb) - return; + return 0; - intel_update_plane(plane, plane->crtc, plane->fb, - intel_plane->crtc_x, intel_plane->crtc_y, - intel_plane->crtc_w, intel_plane->crtc_h, - intel_plane->src_x, intel_plane->src_y, - intel_plane->src_w, intel_plane->src_h); + return intel_update_plane(plane, plane->crtc, plane->fb, + intel_plane->crtc_x, intel_plane->crtc_y, + intel_plane->crtc_w, intel_plane->crtc_h, + intel_plane->src_x, intel_plane->src_y, + intel_plane->src_w, intel_plane->src_h); } void intel_plane_disable(struct drm_plane *plane) -- 1.8.5
[PATCH v5 02/11] drm: Add support_bits parameter to drm_property_create_bitmask()
From: Ville Syrj?l? Make drm_property_create_bitmask() a bit more generic by allowing the caller to specify which bits are in fact supported. This allows multiple callers to use the same enum list, but still create different versions of the same property with different list of supported bits. v5: Fixed the caller of this function in omapdrm to comply with supported bitmask definition. Cc: David Airlie Cc: Tomi Valkeinen Cc: Rob Clark Cc: Sagar Kamble Cc: "Ville Syrj?l?" Cc: Greg Kroah-Hartman Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble Reviewed-by: Rob Clark --- drivers/gpu/drm/drm_crtc.c | 6 +- drivers/gpu/drm/omapdrm/omap_plane.c | 8 +++- include/drm/drm_crtc.h | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 3b7d32d..628d3d3 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2906,7 +2906,8 @@ EXPORT_SYMBOL(drm_property_create_enum); struct drm_property *drm_property_create_bitmask(struct drm_device *dev, int flags, const char *name, const struct drm_prop_enum_list *props, -int num_values) +int num_values, +unsigned int supported_bits) { struct drm_property *property; int i, ret; @@ -2918,6 +2919,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, return NULL; for (i = 0; i < num_values; i++) { + if (!(supported_bits & (1 << i))) + continue; + ret = drm_property_add_enum(property, i, props[i].type, props[i].name); diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 046d5e6..b288f38 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -309,7 +309,13 @@ void omap_plane_install_properties(struct drm_plane *plane, { DRM_REFLECT_Y, "reflect-y" }, }; prop = drm_property_create_bitmask(dev, 0, "rotation", - props, ARRAY_SIZE(props)); + props, ARRAY_SIZE(props), + BIT(DRM_ROTATE_0) | + BIT(DRM_ROTATE_90) | + BIT(DRM_ROTATE_180) | + BIT(DRM_ROTATE_270) | + BIT(DRM_REFLECT_X) | + BIT(DRM_REFLECT_Y)); if (prop == NULL) return; priv->rotation_prop = prop; diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index d5c46c1..41b86d2 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1070,7 +1070,8 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int struct drm_property *drm_property_create_bitmask(struct drm_device *dev, int flags, const char *name, const struct drm_prop_enum_list *props, -int num_values); +int num_values, +unsigned int supported_bits); struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, const char *name, uint64_t min, uint64_t max); -- 1.8.5
[PATCH v5 10/11] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Uma Shankar Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 12 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 86 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 9 5 files changed, 106 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..fcd9e34 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct drm_crtc *crtc; + struct drm_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,16 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) + drm_object_property_set_value(&crtc->base, + dev_priv->rotation_property, 0); + + list_for_each_entry(plane, &dev->mode_config.plane_list, head) + drm_object_property_set_value(&plane->base, + dev_priv->rotation_property, 0); + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..4a4f650 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, dspcntr = I915_READ(reg); /* Mask out pixel format bits in case we change it */ dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; + dspcntr &= ~DISPPLANE_ROTATE_180; + switch (fb->pixel_format) { case DRM_FORMAT_C8: dspcntr |= DISPPLANE_8BPP; @@ -2095,8 +2099,6 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, if (IS_G4X(dev)) dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; - I915_WRITE(reg, dspcntr); - linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); if (INTEL_INFO(dev)->gen >= 4) { @@ -2109,6 +2111,17 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, intel_crtc->dspaddr_offset = linear_offset; } + if (intel_crtc->rotation == BIT(DRM_ROTATE_180)) { + dspcntr |= DISPPLANE_ROTATE_180; + + x += (intel_crtc->config.pipe_src_w - 1); + y += (in
[PATCH v5 01/11] drm: Move DRM_ROTATE bits out of omapdrm into drm_crtc.h
From: Ville Syrj?l? The rotation property stuff should be standardized among all drivers. Move the bits to drm_crtc.h from omap_drv.h. Cc: David Airlie Cc: Tomi Valkeinen Cc: Dave Airlie Cc: Rob Clark Cc: Daniel Vetter Cc: Archit Taneja Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Reviewed-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/omapdrm/omap_drv.h | 7 --- include/drm/drm_crtc.h | 8 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 428b2981..aac8e10 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -119,13 +119,6 @@ struct omap_drm_private { struct omap_drm_irq error_handler; }; -/* this should probably be in drm-core to standardize amongst drivers */ -#define DRM_ROTATE_0 0 -#define DRM_ROTATE_90 1 -#define DRM_ROTATE_180 2 -#define DRM_ROTATE_270 3 -#define DRM_REFLECT_X 4 -#define DRM_REFLECT_Y 5 #ifdef CONFIG_DEBUG_FS int omap_debugfs_init(struct drm_minor *minor); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 71727b6..d5c46c1 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -65,6 +65,14 @@ struct drm_object_properties { uint64_t values[DRM_OBJECT_MAX_PROPERTY]; }; +/* rotation property bits */ +#define DRM_ROTATE_0 0 +#define DRM_ROTATE_90 1 +#define DRM_ROTATE_180 2 +#define DRM_ROTATE_270 3 +#define DRM_REFLECT_X 4 +#define DRM_REFLECT_Y 5 + /* * Note on terminology: here, for brevity and convenience, we refer to connector * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, -- 1.8.5
[PATCH v5 05/11] drm: Add drm_rect rotation functions
From: Ville Syrj?l? Add some helper functions to move drm_rects between different rotated coordinate spaces. One function does the forward transform and another does the inverse. Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Reviewed-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/drm_rect.c | 140 + include/drm/drm_rect.h | 6 ++ 2 files changed, 146 insertions(+) diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c index 7047ca0..631f5af 100644 --- a/drivers/gpu/drm/drm_rect.c +++ b/drivers/gpu/drm/drm_rect.c @@ -293,3 +293,143 @@ void drm_rect_debug_print(const struct drm_rect *r, bool fixed_point) DRM_DEBUG_KMS("%dx%d%+d%+d\n", w, h, r->x1, r->y1); } EXPORT_SYMBOL(drm_rect_debug_print); + +/** + * drm_rect_rotate - Rotate the rectangle + * @r: rectangle to be rotated + * @width: Width of the coordinate space + * @height: Height of the coordinate space + * @rotation: Transformation to be applied + * + * Apply @rotation to the coordinates of rectangle @r. + * + * @width and @height combined with @rotation define + * the location of the new origin. + * + * @width correcsponds to the horizontal and @height + * to the vertical axis of the untransformed coordinate + * space. + */ +void drm_rect_rotate(struct drm_rect *r, +int width, int height, +unsigned int rotation) +{ + struct drm_rect tmp; + + if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { + tmp = *r; + + if (rotation & BIT(DRM_REFLECT_X)) { + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + } + + if (rotation & BIT(DRM_REFLECT_Y)) { + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + } + } + + switch (rotation & 0xf) { + case BIT(DRM_ROTATE_0): + break; + case BIT(DRM_ROTATE_90): + tmp = *r; + r->x1 = tmp.y1; + r->x2 = tmp.y2; + r->y1 = width - tmp.x2; + r->y2 = width - tmp.x1; + break; + case BIT(DRM_ROTATE_180): + tmp = *r; + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + break; + case BIT(DRM_ROTATE_270): + tmp = *r; + r->x1 = height - tmp.y2; + r->x2 = height - tmp.y1; + r->y1 = tmp.x1; + r->y2 = tmp.x2; + break; + default: + break; + } +} +EXPORT_SYMBOL(drm_rect_rotate); + +/** + * drm_rect_rotate_inv - Inverse rotate the rectangle + * @r: rectangle to be rotated + * @width: Width of the coordinate space + * @height: Height of the coordinate space + * @rotation: Transformation whose inverse is to be applied + * + * Apply the inverse of @rotation to the coordinates + * of rectangle @r. + * + * @width and @height combined with @rotation define + * the location of the new origin. + * + * @width correcsponds to the horizontal and @height + * to the vertical axis of the original untransformed + * coordinate space, so that you never have to flip + * them when doing a rotatation and its inverse. + * That is, if you do: + * + * drm_rotate(&r, width, height, rotation); + * drm_rotate_inv(&r, width, height, rotation); + * + * you will always get back the original rectangle. + */ +void drm_rect_rotate_inv(struct drm_rect *r, +int width, int height, +unsigned int rotation) +{ + struct drm_rect tmp; + + switch (rotation & 0xf) { + case BIT(DRM_ROTATE_0): + break; + case BIT(DRM_ROTATE_90): + tmp = *r; + r->x1 = width - tmp.y2; + r->x2 = width - tmp.y1; + r->y1 = tmp.x1; + r->y2 = tmp.x2; + break; + case BIT(DRM_ROTATE_180): + tmp = *r; + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + r->y1 = height - tmp.y2; + r->y2 = height - tmp.y1; + break; + case BIT(DRM_ROTATE_270): + tmp = *r; + r->x1 = tmp.y1; + r->x2 = tmp.y2; + r->y1 = height - tmp.x2; + r->y2 = height - tmp.x1; + break; + default: + break; + } + + if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { + tmp = *r; + + if (rotation & BIT(DRM_REFLECT_X)) { + r->x1 = width - tmp.x2; + r->x2 = width - tmp.x1; + } + + if (rotation & BIT(DRM_
[PATCH v5 07/11] drm/i915: Add 180 degree sprite rotation support
From: Ville Syrj?l? The sprite planes (in fact all display planes starting from gen4) support 180 degree rotation. Add the relevant low level bits to the sprite code to make use of that feature. The upper layers are not yet plugged in. v2: HSW handles the rotated buffer offset automagically Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_drv.h| 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 + 3 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index abd18cd..57906c5 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3637,6 +3637,7 @@ #define DVS_YUV_ORDER_UYVY (1<<16) #define DVS_YUV_ORDER_YVYU (2<<16) #define DVS_YUV_ORDER_VYUY (3<<16) +#define DVS_ROTATE_180 (1<<15) #define DVS_DEST_KEY (1<<2) #define DVS_TRICKLE_FEED_DISABLE (1<<14) #define DVS_TILED(1<<10) @@ -3707,6 +3708,7 @@ #define SPRITE_YUV_ORDER_UYVY(1<<16) #define SPRITE_YUV_ORDER_YVYU(2<<16) #define SPRITE_YUV_ORDER_VYUY(3<<16) +#define SPRITE_ROTATE_180(1<<15) #define SPRITE_TRICKLE_FEED_DISABLE (1<<14) #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) @@ -3780,6 +3782,7 @@ #define SP_YUV_ORDER_UYVY(1<<16) #define SP_YUV_ORDER_YVYU(2<<16) #define SP_YUV_ORDER_VYUY(3<<16) +#define SP_ROTATE_180(1<<15) #define SP_TILED (1<<10) #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184) #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bc..85864fc 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -397,6 +397,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + unsigned int rotation; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 336ae6c..477d4d7 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -60,6 +60,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, sprctl &= ~SP_PIXFORMAT_MASK; sprctl &= ~SP_YUV_BYTE_ORDER_MASK; sprctl &= ~SP_TILED; + sprctl &= ~SP_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_YUYV: @@ -131,6 +132,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SP_ROTATE_180; + + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); @@ -238,6 +247,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, sprctl &= ~SPRITE_RGB_ORDER_RGBX; sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; sprctl &= ~SPRITE_TILED; + sprctl &= ~SPRITE_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -299,6 +309,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SPRITE_ROTATE_180; + + /* HSW does this automagically in hardware */ + if (!IS_HASWELL(dev)) { + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + } + I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); @@ -422,6 +443,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, dvscntr &= ~DVS_RGB_ORDER_XBGR; dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; dvscntr &= ~DVS_TILED; + dvscntr &= ~DVS_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -478,6 +500,14 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
[PATCH v5 11/11] drm/i915: Calling rotate and inverse rotate transformations after clipping
From: Sagar Kamble With clipped sprites these transformations are not working. these functions transform complete sprite irrespective of clipping present. This leads to invisible portion of sprite show up when rotate 180 if it was out of visible area before. v4: Moved rotate transform for source rectangle after clipping. Added rotate and inverse rotate transform for destination rect. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/intel_sprite.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 62b9f84..799f6a9 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -769,9 +769,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, max_scale = intel_plane->max_downscale << 16; min_scale = intel_plane->can_scale ? 1 : (1 << 16); - drm_rect_rotate(&src, fb->width << 16, fb->height << 16, - intel_plane->rotation); - hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale); BUG_ON(hscale < 0); @@ -785,6 +782,13 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, crtc_w = drm_rect_width(&dst); crtc_h = drm_rect_height(&dst); + drm_rect_rotate(&src, fb->width << 16, fb->height << 16, + intel_plane->rotation); + + drm_rect_rotate(&dst, intel_crtc->config.pipe_src_w, + intel_crtc->config.pipe_src_h, + intel_plane->rotation); + if (visible) { /* check again in case clipping clamped the results */ hscale = drm_rect_calc_hscale(&src, &dst, min_scale, max_scale); @@ -811,7 +815,11 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, drm_rect_height(&dst) * vscale - drm_rect_height(&src)); drm_rect_rotate_inv(&src, fb->width << 16, fb->height << 16, - intel_plane->rotation); + intel_plane->rotation); + + drm_rect_rotate_inv(&dst, intel_crtc->config.pipe_src_w, + intel_crtc->config.pipe_src_h, + intel_plane->rotation); /* sanity check to make sure the src viewport wasn't enlarged */ WARN_ON(src.x1 < (int) src_x || -- 1.8.5
[PATCH v5 07/11] drm/i915: Add 180 degree sprite rotation support
From: Ville Syrj?l? The sprite planes (in fact all display planes starting from gen4) support 180 degree rotation. Add the relevant low level bits to the sprite code to make use of that feature. The upper layers are not yet plugged in. v2: HSW handles the rotated buffer offset automagically Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? --- drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_drv.h| 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 + 3 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index abd18cd..57906c5 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3637,6 +3637,7 @@ #define DVS_YUV_ORDER_UYVY (1<<16) #define DVS_YUV_ORDER_YVYU (2<<16) #define DVS_YUV_ORDER_VYUY (3<<16) +#define DVS_ROTATE_180 (1<<15) #define DVS_DEST_KEY (1<<2) #define DVS_TRICKLE_FEED_DISABLE (1<<14) #define DVS_TILED(1<<10) @@ -3707,6 +3708,7 @@ #define SPRITE_YUV_ORDER_UYVY(1<<16) #define SPRITE_YUV_ORDER_YVYU(2<<16) #define SPRITE_YUV_ORDER_VYUY(3<<16) +#define SPRITE_ROTATE_180(1<<15) #define SPRITE_TRICKLE_FEED_DISABLE (1<<14) #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) @@ -3780,6 +3782,7 @@ #define SP_YUV_ORDER_UYVY(1<<16) #define SP_YUV_ORDER_YVYU(2<<16) #define SP_YUV_ORDER_VYUY(3<<16) +#define SP_ROTATE_180(1<<15) #define SP_TILED (1<<10) #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184) #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bc..85864fc 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -397,6 +397,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + unsigned int rotation; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 336ae6c..477d4d7 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -60,6 +60,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, sprctl &= ~SP_PIXFORMAT_MASK; sprctl &= ~SP_YUV_BYTE_ORDER_MASK; sprctl &= ~SP_TILED; + sprctl &= ~SP_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_YUYV: @@ -131,6 +132,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SP_ROTATE_180; + + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); @@ -238,6 +247,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, sprctl &= ~SPRITE_RGB_ORDER_RGBX; sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; sprctl &= ~SPRITE_TILED; + sprctl &= ~SPRITE_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -299,6 +309,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SPRITE_ROTATE_180; + + /* HSW does this automagically in hardware */ + if (!IS_HASWELL(dev)) { + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + } + I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); @@ -422,6 +443,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, dvscntr &= ~DVS_RGB_ORDER_XBGR; dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; dvscntr &= ~DVS_TILED; + dvscntr &= ~DVS_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -478,6 +500,14 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb-
[PATCH v5 06/11] drm: Add drm_rotation_simplify()
From: Ville Syrj?l? drm_rotation_simplify() can be used to eliminate unsupported rotation flags. It will check if any unsupported flags are present, and if so it will modify the rotation to an alternate form by adding 180 degrees to rotation angle, and flipping the reflect x and y bits. The hope is that this identity transform will eliminate the unsupported flags. Of course that might not result in any more supported rotation, so the caller is still responsible for checking the result afterwards. Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? --- drivers/gpu/drm/drm_crtc.c | 30 ++ include/drm/drm_crtc.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index e7bbbad..30e0008 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4006,6 +4006,36 @@ int drm_format_vert_chroma_subsampling(uint32_t format) EXPORT_SYMBOL(drm_format_vert_chroma_subsampling); /** + * drm_rotation_simplify() - Try to simplify the rotation + * @rotation: Rotation to be simplified + * @supported_rotations: Supported rotations + * + * Attempt to simplify the rotation to a form that is supported. + * Eg. if the hardware supports everything except DRM_REFLECT_X + * one could call this function like this: + * + * drm_rotation_simplify(rotation, BIT(DRM_ROTATE_0) | + * BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_180) | + * BIT(DRM_ROTATE_270) | BIT(DRM_REFLECT_Y)); + * + * to eliminate the DRM_ROTATE_X flag. Depending on what kind of + * transforms the hardware supports, this function may not + * be able to produce a supported transform, so the caller should + * check the result afterwards. + */ +unsigned int drm_rotation_simplify(unsigned int rotation, + unsigned int supported_rotations) +{ + if (rotation & ~supported_rotations) { + rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y); + rotation = (rotation & ~0xf) | BIT((ffs(rotation & 0xf) + 1) % 4); + } + + return rotation; +} +EXPORT_SYMBOL(drm_rotation_simplify); + +/** * drm_mode_config_init - initialize DRM mode_configuration structure * @dev: DRM device * diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 4b3ac70..18f2eed 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1185,6 +1185,8 @@ extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, unsigned int supported_rotations); +extern unsigned int drm_rotation_simplify(unsigned int rotation, + unsigned int supported_rotations); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH v5 03/11] drm: Add drm_mode_create_rotation_property()
From: Ville Syrj?l? Add a function to create a standards compliant rotation property. v4: For creating rotation bitmask property send number of values as only number of set rotations Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble --- drivers/gpu/drm/drm_crtc.c | 33 + include/drm/drm_crtc.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 628d3d3..e7bbbad 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -4118,3 +4118,36 @@ void drm_mode_config_cleanup(struct drm_device *dev) idr_destroy(&dev->mode_config.crtc_idr); } EXPORT_SYMBOL(drm_mode_config_cleanup); + +/* +* Function to get number of bits set in bitmask +* using Brian Kernighan's Algorithm +*/ +unsigned int bits_set(unsigned int n) +{ + unsigned int count = 0; + + while (n) { + n &= (n-1); + count ++; + } + return count; +} + +struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, + unsigned int supported_rotations) +{ + static const struct drm_prop_enum_list props[] = { + { DRM_ROTATE_0, "rotate-0" }, + { DRM_ROTATE_90, "rotate-90" }, + { DRM_ROTATE_180, "rotate-180" }, + { DRM_ROTATE_270, "rotate-270" }, + { DRM_REFLECT_X, "reflect-x" }, + { DRM_REFLECT_Y, "reflect-y" }, + }; + + return drm_property_create_bitmask(dev, 0, "rotation", + props, bits_set(supported_rotations), + supported_rotations); +} +EXPORT_SYMBOL(drm_mode_create_rotation_property); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 41b86d2..4b3ac70 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1183,6 +1183,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane); extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_vert_chroma_subsampling(uint32_t format); extern const char *drm_get_format_name(uint32_t format); +extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, + unsigned int supported_rotations); /* Helpers */ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, -- 1.8.5
[PATCH v5 09/11] drm/i915: Add rotation property for sprites
From: Ville Syrj?l? Sprite planes support 180 degree rotation. The lower layers are now in place, so hook in the standard rotation property to expose the feature to the users. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Reviewed-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 42 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index fa37dfd..ea2efc3 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1548,6 +1548,7 @@ typedef struct drm_i915_private { struct drm_property *broadcast_rgb_property; struct drm_property *force_audio_property; + struct drm_property *rotation_property; uint32_t hw_context_size; struct list_head context_list; diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 511934c..62b9f84 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1047,6 +1047,30 @@ out_unlock: return ret; } +static int intel_plane_set_property(struct drm_plane *plane, + struct drm_property *prop, + uint64_t val) +{ + struct drm_i915_private *dev_priv = plane->dev->dev_private; + struct intel_plane *intel_plane = to_intel_plane(plane); + uint64_t old_val; + int ret = -ENOENT; + + if (prop == dev_priv->rotation_property) { + /* exactly one rotation angle please */ + if (hweight32(val & 0xf) != 1) + return -EINVAL; + + old_val = intel_plane->rotation; + intel_plane->rotation = val; + ret = intel_plane_restore(plane); + if (ret) + intel_plane->rotation = old_val; + } + + return ret; +} + int intel_plane_restore(struct drm_plane *plane) { struct intel_plane *intel_plane = to_intel_plane(plane); @@ -1073,6 +1097,7 @@ static const struct drm_plane_funcs intel_plane_funcs = { .update_plane = intel_update_plane, .disable_plane = intel_disable_plane, .destroy = intel_destroy_plane, + .set_property = intel_plane_set_property, }; static uint32_t ilk_plane_formats[] = { @@ -1109,6 +1134,7 @@ static uint32_t vlv_plane_formats[] = { int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) { + struct drm_i915_private *dev_priv = dev->dev_private; struct intel_plane *intel_plane; unsigned long possible_crtcs; const uint32_t *plane_formats; @@ -1183,8 +1209,22 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) &intel_plane_funcs, plane_formats, num_plane_formats, false); - if (ret) + if (ret) { kfree(intel_plane); + goto out; + } + + if (!dev_priv->rotation_property) + dev_priv->rotation_property = + drm_mode_create_rotation_property(dev, + BIT(DRM_ROTATE_0) | + BIT(DRM_ROTATE_180)); + + if (dev_priv->rotation_property) + drm_object_attach_property(&intel_plane->base.base, + dev_priv->rotation_property, + intel_plane->rotation); + out: return ret; } -- 1.8.5
[PATCH v5 08/11] drm/i915: Make intel_plane_restore() return an error
From: Ville Syrj?l? Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller. This will be used for rollback purposes when setting properties fails. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Reviewed-by: Sagar Kamble Tested-by: Sagar Kamble --- drivers/gpu/drm/i915/intel_drv.h| 2 +- drivers/gpu/drm/i915/intel_sprite.c | 14 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 85864fc..7a79b8e 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -897,7 +897,7 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob); int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane); void intel_flush_primary_plane(struct drm_i915_private *dev_priv, enum plane plane); -void intel_plane_restore(struct drm_plane *plane); +int intel_plane_restore(struct drm_plane *plane); void intel_plane_disable(struct drm_plane *plane); int intel_sprite_set_colorkey(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 477d4d7..511934c 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1047,18 +1047,18 @@ out_unlock: return ret; } -void intel_plane_restore(struct drm_plane *plane) +int intel_plane_restore(struct drm_plane *plane) { struct intel_plane *intel_plane = to_intel_plane(plane); if (!plane->crtc || !plane->fb) - return; + return 0; - intel_update_plane(plane, plane->crtc, plane->fb, - intel_plane->crtc_x, intel_plane->crtc_y, - intel_plane->crtc_w, intel_plane->crtc_h, - intel_plane->src_x, intel_plane->src_y, - intel_plane->src_w, intel_plane->src_h); + return intel_update_plane(plane, plane->crtc, plane->fb, + intel_plane->crtc_x, intel_plane->crtc_y, + intel_plane->crtc_w, intel_plane->crtc_h, + intel_plane->src_x, intel_plane->src_y, + intel_plane->src_w, intel_plane->src_h); } void intel_plane_disable(struct drm_plane *plane) -- 1.8.5
[PATCH v5 04/11] drm/omap: Switch omapdrm over to drm_mode_create_rotation_property()
From: Ville Syrj?l? Use the new drm_mode_create_rotation_property() in omapdrm. v5: Fixed conflict due to change in the prior patch in call to drm_property_create_bitmask() Cc: David Airlie Cc: Rob Clark Cc: Sagar Kamble Cc: "Ville Syrj?l?" Cc: Tomi Valkeinen Cc: Greg Kroah-Hartman Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble Reviewed-by: Rob Clark --- drivers/gpu/drm/omapdrm/omap_plane.c | 23 +++ 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index b288f38..fee8f35 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -300,22 +300,13 @@ void omap_plane_install_properties(struct drm_plane *plane, if (priv->has_dmm) { prop = priv->rotation_prop; if (!prop) { - const struct drm_prop_enum_list props[] = { - { DRM_ROTATE_0, "rotate-0" }, - { DRM_ROTATE_90, "rotate-90" }, - { DRM_ROTATE_180, "rotate-180" }, - { DRM_ROTATE_270, "rotate-270" }, - { DRM_REFLECT_X, "reflect-x" }, - { DRM_REFLECT_Y, "reflect-y" }, - }; - prop = drm_property_create_bitmask(dev, 0, "rotation", - props, ARRAY_SIZE(props), - BIT(DRM_ROTATE_0) | - BIT(DRM_ROTATE_90) | - BIT(DRM_ROTATE_180) | - BIT(DRM_ROTATE_270) | - BIT(DRM_REFLECT_X) | - BIT(DRM_REFLECT_Y)); + prop = drm_mode_create_rotation_property(dev, + BIT(DRM_ROTATE_0) | + BIT(DRM_ROTATE_90) | + BIT(DRM_ROTATE_180) | + BIT(DRM_ROTATE_270) | + BIT(DRM_REFLECT_X) | + BIT(DRM_REFLECT_Y)); if (prop == NULL) return; priv->rotation_prop = prop; -- 1.8.5
[PATCH v5 1/1] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. v5: Resetting property in i915_driver_lastclose properly for planes and crtcs. Fixed linear offset calculation that was off by 1 w.r.t width in i9xx_update_plane and ironlake_update_plane. Removed tab based indentation and unnecessary braces in intel_crtc_set_property and intel_update_fbc. FBC and flip related checks should be done only for valid crtcs. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Uma Shankar Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 17 +++ drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 86 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 9 5 files changed, 111 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..19e22a2 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct intel_crtc *crtc; + struct intel_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,21 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { + crtc->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&crtc->base.base, + dev_priv->rotation_property, + crtc->rotation); + } + list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) { + plane->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&plane->base.base, + dev_priv->rotation_property, + plane->rotation); + } + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..fad43b0 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, dspcntr = I915_READ(reg); /* Mask out pixel format bits in case we change it */ dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; + dspcntr &= ~DISPPLANE_ROTATE_180; + switch (fb->pixel_format) { case DRM_FORMAT_C8: dspcntr |= DISPPLANE_8BPP; @@ -2095,8 +2099,6 @@ sta
[PATCH v3 1/1] drm/i915: Add 180 degree sprite rotation support
From: Ville Syrj?l? The sprite planes (in fact all display planes starting from gen4) support 180 degree rotation. Add the relevant low level bits to the sprite code to make use of that feature. The upper layers are not yet plugged in. v2: HSW handles the rotated buffer offset automagically v3: BDW also handles the rotated buffer offset automagically Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_drv.h| 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 + 3 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index abd18cd..57906c5 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3637,6 +3637,7 @@ #define DVS_YUV_ORDER_UYVY (1<<16) #define DVS_YUV_ORDER_YVYU (2<<16) #define DVS_YUV_ORDER_VYUY (3<<16) +#define DVS_ROTATE_180 (1<<15) #define DVS_DEST_KEY (1<<2) #define DVS_TRICKLE_FEED_DISABLE (1<<14) #define DVS_TILED(1<<10) @@ -3707,6 +3708,7 @@ #define SPRITE_YUV_ORDER_UYVY(1<<16) #define SPRITE_YUV_ORDER_YVYU(2<<16) #define SPRITE_YUV_ORDER_VYUY(3<<16) +#define SPRITE_ROTATE_180(1<<15) #define SPRITE_TRICKLE_FEED_DISABLE (1<<14) #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) @@ -3780,6 +3782,7 @@ #define SP_YUV_ORDER_UYVY(1<<16) #define SP_YUV_ORDER_YVYU(2<<16) #define SP_YUV_ORDER_VYUY(3<<16) +#define SP_ROTATE_180(1<<15) #define SP_TILED (1<<10) #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184) #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bc..85864fc 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -397,6 +397,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + unsigned int rotation; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 336ae6c..2076878 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -60,6 +60,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, sprctl &= ~SP_PIXFORMAT_MASK; sprctl &= ~SP_YUV_BYTE_ORDER_MASK; sprctl &= ~SP_TILED; + sprctl &= ~SP_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_YUYV: @@ -131,6 +132,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SP_ROTATE_180; + + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); @@ -238,6 +247,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, sprctl &= ~SPRITE_RGB_ORDER_RGBX; sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; sprctl &= ~SPRITE_TILED; + sprctl &= ~SPRITE_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -299,6 +309,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SPRITE_ROTATE_180; + + /* HSW and BDW does this automagically in hardware */ + if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + } + I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); @@ -422,6 +443,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, dvscntr &= ~DVS_RGB_ORDER_XBGR; dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; dvscntr &= ~DVS_TILED; + dvscntr &= ~DVS_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -478,6 +500,14 @@ ilk_upd
[PATCH v6 1/1] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. v5: Resetting property in i915_driver_lastclose properly for planes and crtcs. Fixed linear offset calculation that was off by 1 w.r.t width in i9xx_update_plane and ironlake_update_plane. Removed tab based indentation and unnecessary braces in intel_crtc_set_property and intel_update_fbc. FBC and flip related checks should be done only for valid crtcs. v6: Minor nits in FBC disable checks for comments in intel_crtc_set_property and positioning the disable code in intel_update_fbc. Testcase: igt/kms_plane_rotation_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Uma Shankar Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 17 +++ drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 86 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 8 5 files changed, 110 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..19e22a2 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct intel_crtc *crtc; + struct intel_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,21 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { + crtc->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&crtc->base.base, + dev_priv->rotation_property, + crtc->rotation); + } + list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) { + plane->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&plane->base.base, + dev_priv->rotation_property, + plane->rotation); + } + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..f6fee29 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, dspcntr = I915_READ(reg); /* Mask out pixel format bits in case we change it */ dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; +
[PATCH v3 1/1] drm/i915: Add 180 degree sprite rotation support
From: Ville Syrj?l? The sprite planes (in fact all display planes starting from gen4) support 180 degree rotation. Add the relevant low level bits to the sprite code to make use of that feature. The upper layers are not yet plugged in. v2: HSW handles the rotated buffer offset automagically v3: BDW also handles the rotated buffer offset automagically Testcase: igt/kms_plane_rotation_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: Ville Syrj?l? Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_drv.h| 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 + 3 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index abd18cd..57906c5 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3637,6 +3637,7 @@ #define DVS_YUV_ORDER_UYVY (1<<16) #define DVS_YUV_ORDER_YVYU (2<<16) #define DVS_YUV_ORDER_VYUY (3<<16) +#define DVS_ROTATE_180 (1<<15) #define DVS_DEST_KEY (1<<2) #define DVS_TRICKLE_FEED_DISABLE (1<<14) #define DVS_TILED(1<<10) @@ -3707,6 +3708,7 @@ #define SPRITE_YUV_ORDER_UYVY(1<<16) #define SPRITE_YUV_ORDER_YVYU(2<<16) #define SPRITE_YUV_ORDER_VYUY(3<<16) +#define SPRITE_ROTATE_180(1<<15) #define SPRITE_TRICKLE_FEED_DISABLE (1<<14) #define SPRITE_INT_GAMMA_ENABLE (1<<13) #define SPRITE_TILED (1<<10) @@ -3780,6 +3782,7 @@ #define SP_YUV_ORDER_UYVY(1<<16) #define SP_YUV_ORDER_YVYU(2<<16) #define SP_YUV_ORDER_VYUY(3<<16) +#define SP_ROTATE_180(1<<15) #define SP_TILED (1<<10) #define _SPALINOFF (VLV_DISPLAY_BASE + 0x72184) #define _SPASTRIDE (VLV_DISPLAY_BASE + 0x72188) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bc..85864fc 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -397,6 +397,7 @@ struct intel_plane { unsigned int crtc_w, crtc_h; uint32_t src_x, src_y; uint32_t src_w, src_h; + unsigned int rotation; /* Since we need to change the watermarks before/after * enabling/disabling the planes, we need to store the parameters here diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 336ae6c..2076878 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -60,6 +60,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, sprctl &= ~SP_PIXFORMAT_MASK; sprctl &= ~SP_YUV_BYTE_ORDER_MASK; sprctl &= ~SP_TILED; + sprctl &= ~SP_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_YUYV: @@ -131,6 +132,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SP_ROTATE_180; + + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); @@ -238,6 +247,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, sprctl &= ~SPRITE_RGB_ORDER_RGBX; sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; sprctl &= ~SPRITE_TILED; + sprctl &= ~SPRITE_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_XBGR: @@ -299,6 +309,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, pixel_size, fb->pitches[0]); linear_offset -= sprsurf_offset; + if (intel_plane->rotation == BIT(DRM_ROTATE_180)) { + sprctl |= SPRITE_ROTATE_180; + + /* HSW and BDW does this automagically in hardware */ + if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { + x += src_w; + y += src_h; + linear_offset += src_h * fb->pitches[0] + src_w * pixel_size; + } + } + I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); @@ -422,6 +443,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, dvscntr &= ~DVS_RGB_ORDER_XBGR; dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; dvscntr &= ~DVS_TILED; + dvscntr &= ~DVS_ROTATE_180; switch (fb->pixel_format) { case DRM_FORMAT_X
[PATCH v7 1/1] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. v5: Resetting property in i915_driver_lastclose properly for planes and crtcs. Fixed linear offset calculation that was off by 1 w.r.t width in i9xx_update_plane and ironlake_update_plane. Removed tab based indentation and unnecessary braces in intel_crtc_set_property and intel_update_fbc. FBC and flip related checks should be done only for valid crtcs. v6: Minor nits in FBC disable checks for comments in intel_crtc_set_property and positioning the disable code in intel_update_fbc. v7: In case rotation property on inactive crtc is updated, we return successfully printing debug log as crtc is inactive and only property change is preserved. Testcase: igt/kms_plane_rotation_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Uma Shankar Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 17 +++ drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 86 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 8 5 files changed, 110 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..19e22a2 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct intel_crtc *crtc; + struct intel_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,21 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { + crtc->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&crtc->base.base, + dev_priv->rotation_property, + crtc->rotation); + } + list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) { + plane->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&plane->base.base, + dev_priv->rotation_property, + plane->rotation); + } + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..f6fee29 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_frame
[PATCH v7 1/1] drm/i915: Add 180 degree primary plane rotation support
From: Sagar Kamble Primary planes support 180 degree rotation. Expose the feature through rotation drm property. v2: Calculating linear/tiled offsets based on pipe source width and height. Added 180 degree rotation support in ironlake_update_plane. v3: Checking if CRTC is active before issueing update_plane. Added wait for vblank to make sure we dont overtake page flips. Disabling FBC since it does not work with rotated planes. v4: Updated rotation checks for pending flips, fbc disable. Creating rotation property only for Gen4 onwards. Property resetting as part of lastclose. v5: Resetting property in i915_driver_lastclose properly for planes and crtcs. Fixed linear offset calculation that was off by 1 w.r.t width in i9xx_update_plane and ironlake_update_plane. Removed tab based indentation and unnecessary braces in intel_crtc_set_property and intel_update_fbc. FBC and flip related checks should be done only for valid crtcs. v6: Minor nits in FBC disable checks for comments in intel_crtc_set_property and positioning the disable code in intel_update_fbc. v7: In case rotation property on inactive crtc is updated, we return successfully printing debug log as crtc is inactive and only property change is preserved. Testcase: igt/kms_plane_rotation_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: vijay.a.purushothaman at intel.com Signed-off-by: Uma Shankar Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_dma.c | 17 +++ drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 90 ++-- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 8 5 files changed, 114 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 258b1be..19e22a2 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1836,6 +1836,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; + struct intel_crtc *crtc; + struct intel_plane *plane; /* On gen6+ we refuse to init without kms enabled, but then the drm core * goes right around and calls lastclose. Check for this and don't clean @@ -1843,6 +1845,21 @@ void i915_driver_lastclose(struct drm_device * dev) if (!dev_priv) return; + if (dev_priv->rotation_property) { + list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { + crtc->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&crtc->base.base, + dev_priv->rotation_property, + crtc->rotation); + } + list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) { + plane->rotation = BIT(DRM_ROTATE_0); + drm_object_property_set_value(&plane->base.base, + dev_priv->rotation_property, + plane->rotation); + } + } + if (drm_core_check_feature(dev, DRIVER_MODESET)) { intel_fbdev_restore_mode(dev); vga_switcheroo_process_delayed_switch(); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 57906c5..d3000c4 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3553,6 +3553,7 @@ #define DISPPLANE_NO_LINE_DOUBLE 0 #define DISPPLANE_STEREO_POLARITY_FIRST 0 #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) +#define DISPPLANE_ROTATE_180 (1<<15) #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ #define DISPPLANE_TILED (1<<10) #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4d4a0d9..8a730c3 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, unsigned long linear_offset; u32 dspcntr; u32 reg; + int pixel_size; switch (plane) { case 0: @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, return -EINVAL; } + pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); intel_fb = to_intel_framebuffer(fb); obj = intel_fb->obj; @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_frame
[PATCH 1/1] drm/i915: Enabling 128x128 and 256x256 ARGB Cursor Support
From: Sagar Kamble With this patch we allow larger cursor planes of sizes 128x128 and 256x256. Planning to extend kms_cursor_crc test for verifying these larger planes. Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: G, Pallavi Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 4 drivers/gpu/drm/i915/intel_display.c | 25 - 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 2f564ce..2fee3a2 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3522,7 +3522,11 @@ /* New style CUR*CNTR flags */ #define CURSOR_MODE 0x27 #define CURSOR_MODE_DISABLE 0x00 +#define CURSOR_MODE_128_32B_AX 0x02 +#define CURSOR_MODE_256_32B_AX 0x03 #define CURSOR_MODE_64_32B_AX 0x07 +#define CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX) +#define CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX) #define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) #define MCURSOR_PIPE_SELECT (1 << 28) #define MCURSOR_PIPE_A 0x00 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f19e6ea..00b51f3 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7411,10 +7411,18 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR(pipe)); if (base) { cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + if (width == 64) + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 128) + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 256) + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; + cntl |= pipe << 28; /* Connect to correct pipe */ } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); @@ -7439,10 +7447,17 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR_IVB(pipe)); if (base) { cntl &= ~CURSOR_MODE; - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + if (width == 64) + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 128) + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 256) + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); cntl |= CURSOR_MODE_DISABLE; @@ -7538,9 +7553,9 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto finish; } - /* Currently we only support 64x64 cursors */ - if (width != 64 || height != 64) { - DRM_ERROR("we currently only support 64x64 cursors\n"); + /* Check for which cursor types we support */ + if (width > 256 || height > 256) { + DRM_ERROR("We currently only support 64x64, 128x128, 256x256 cursors\n"); return -EINVAL; } -- 1.8.5
[PATCH v2 1/1] drm/i915: Enabling 128x128 and 256x256 ARGB Cursor Support
From: Sagar Kamble With this patch we allow larger cursor planes of sizes 128x128 and 256x256. v2: Added more precise check on size while setting cursor plane. Testcase: igt/kms_cursor_crc Cc: Daniel Vetter Cc: Jani Nikula Cc: David Airlie Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Signed-off-by: G, Pallavi Signed-off-by: Sagar Kamble --- drivers/gpu/drm/i915/i915_reg.h | 4 drivers/gpu/drm/i915/intel_display.c | 28 +++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 2f564ce..2fee3a2 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -3522,7 +3522,11 @@ /* New style CUR*CNTR flags */ #define CURSOR_MODE 0x27 #define CURSOR_MODE_DISABLE 0x00 +#define CURSOR_MODE_128_32B_AX 0x02 +#define CURSOR_MODE_256_32B_AX 0x03 #define CURSOR_MODE_64_32B_AX 0x07 +#define CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX) +#define CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX) #define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) #define MCURSOR_PIPE_SELECT (1 << 28) #define MCURSOR_PIPE_A 0x00 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f19e6ea..d036b41 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7411,10 +7411,18 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR(pipe)); if (base) { cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + if (width == 64) + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 128) + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 256) + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; + cntl |= pipe << 28; /* Connect to correct pipe */ } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); @@ -7439,10 +7447,17 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) bool visible = base != 0; if (intel_crtc->cursor_visible != visible) { + int16_t width = intel_crtc->cursor_width; uint32_t cntl = I915_READ(CURCNTR_IVB(pipe)); if (base) { cntl &= ~CURSOR_MODE; - cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + if (width == 64) + cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 128) + cntl |= CURSOR_MODE_128_ARGB_AX | MCURSOR_GAMMA_ENABLE; + else if (width == 256) + cntl |= CURSOR_MODE_256_ARGB_AX | MCURSOR_GAMMA_ENABLE; } else { cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); cntl |= CURSOR_MODE_DISABLE; @@ -7538,9 +7553,12 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto finish; } - /* Currently we only support 64x64 cursors */ - if (width != 64 || height != 64) { - DRM_ERROR("we currently only support 64x64 cursors\n"); + /* Check for which cursor types we support */ + if ((!(width == 64 && height == 64) && IS_GEN2(dev)) || + (!(width == 64 && height == 64) +&& !(width == 128 && height == 128) +&& !(width == 256 && height == 256))) { + DRM_ERROR("Cursor dimension is not supported\n"); return -EINVAL; } -- 1.8.5