summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/rcar-du/rcar_du_plane.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-15drm: Nuke fb->pixel_formatVille Syrjälä1-2/+2
Replace uses of fb->pixel_format with fb->format->format. Less duplicated information is a good thing. Note that coccinelle failed to eliminate the "/* fourcc format */" comment from drm_framebuffer.h, so I had to do that part manually. @@ struct drm_framebuffer *FB; expression E; @@ drm_helper_mode_fill_fb_struct(...) { ... - FB->pixel_format = E; ... } @@ struct drm_framebuffer *FB; expression E; @@ i9xx_get_initial_plane_config(...) { ... - FB->pixel_format = E; ... } @@ struct drm_framebuffer *FB; expression E; @@ ironlake_get_initial_plane_config(...) { ... - FB->pixel_format = E; ... } @@ struct drm_framebuffer *FB; expression E; @@ skylake_get_initial_plane_config(...) { ... - FB->pixel_format = E; ... } @@ struct drm_framebuffer *a; struct drm_framebuffer b; @@ ( - a->pixel_format + a->format->format | - b.pixel_format + b.format->format ) @@ struct drm_plane_state *a; struct drm_plane_state b; @@ ( - a->fb->pixel_format + a->fb->format->format | - b.fb->pixel_format + b.fb->format->format ) @@ struct drm_crtc *CRTC; @@ ( - CRTC->primary->fb->pixel_format + CRTC->primary->fb->format->format | - CRTC->primary->state->fb->pixel_format + CRTC->primary->state->fb->format->format ) @@ struct drm_mode_set *set; @@ ( - set->fb->pixel_format + set->fb->format->format | - set->crtc->primary->fb->pixel_format + set->crtc->primary->fb->format->format ) @@ @@ struct drm_framebuffer { ... - uint32_t pixel_format; ... }; v2: Fix commit message (Laurent) Rebase due to earlier removal of many fb->pixel_format uses, including the 'fb->format = drm_format_info(fb->format->format);' snafu v3: Adjusted the semantic patch a bit and regenerated due to code changes Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1) Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: http://patchwork.freedesktop.org/patch/msgid/1481751175-18463-1-git-send-email-ville.syrjala@linux.intel.com
2016-07-29drm: rcar: use generic code for managing zpos plane propertyBenjamin Gaignard1-7/+2
version 6: rebased patch on top rcar-du changes for zpos version 4: fix null pointer issue while setting zpos in plane reset function This patch replaces zpos property handling custom code in rcar DRM driver with calls to generic DRM code. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
2016-06-02drm/rcar-du: Use for_each_*_in_stateDaniel Vetter1-12/+8
We want to hide drm_atomic_state internals better. v2: Use drm_crtc_mask (Maarten). Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1464818821-5736-5-git-send-email-daniel.vetter@ffwll.ch
2016-05-17drm: Drop plane argument from __drm_atomic_helper_plane_destroy_stateDaniel Vetter1-1/+1
It's unused, and really this helper should only look at the state structure and nothing else. v2: Fix commit message (Laurent). v3: Rebase onto mtk driver merge. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Eric Anholt <eric@anholt.net> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Cc: Inki Dae <inki.dae@samsung.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Mark Yao <mark.yao@rock-chips.com> Acked-by: Thierry Reding <thierry.reding@gmail.com> Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Eric Anholt <eric@anholt.net> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1462804451-15318-2-git-send-email-daniel.vetter@ffwll.ch
2016-02-23drm: rcar-du: Add R8A7795 device supportLaurent Pinchart1-11/+38
Document the R8A7795-specific DT bindings and support them in the driver. The HDMI and LVDS outputs are currently not supported. Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-23drm: rcar-du: Fix compile warning on 64-bit platformsKoji Matsuoka1-4/+4
Use %tu instead of %u to print difference between pointers. Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-23drm: rcar-du: Expose the VSP1 compositor through KMS planesLaurent Pinchart1-5/+2
On R-Car Gen3 SoCs the DU lost its ability to access memory directly and needs to work in conjunction with the VSP to do so. This commit handles the VSP internally to hide it from the user. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Move plane allocator to rcar_du_plane.cLaurent Pinchart1-0/+286
The plane allocator is specific to DU planes and won't be used for VSP-based planes, move it with the rest of the DU planes code where it belongs. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Restart the DU group when a plane source changesLaurent Pinchart1-2/+20
Plane sources are configured by the VSPS bit in the PnDDCR4 register. Although the datasheet states that the bit is updated during vertical blanking, it seems that updates only occur when the DU group is held in reset through the DSYSR.DRES bit. Restart the group if the source changes. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Add VSP1 compositor supportLaurent Pinchart1-35/+51
Configure the plane source at plane setup time to source frames from memory or from the VSP1. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Add VSP1 support to the planes allocatorLaurent Pinchart1-0/+1
The R8A7790 DU can source frames directly from the VSP1 devices VSPD0 and VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0 or DU0/1 plane 1. Allocate the correct fixed plane when sourcing frames from VSPD0 or VSPD1, and allocate planes in reverse index order otherwise to ensure maximum availability of planes 0 and 1. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Refactor plane setupLaurent Pinchart1-18/+21
Rename plane setup functions using more explicit names, and use local variables to store intermediate values to increase readability. This also prepares for VSP compositor support. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2016-02-20drm: rcar-du: Compute plane DDCR4 register value directlyLaurent Pinchart1-10/+3
There's no need for a read-modify-write pattern, all register bits can be set explicitly. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-12-11drm: Pass 'name' to drm_universal_plane_init()Ville Syrjälä1-1/+2
Done with coccinelle for the most part. It choked on msm/mdp/mdp5/mdp5_plane.c like so: "BAD:!!!!! enum drm_plane_type type;" No idea how to deal with that, so I just fixed that up by hand. Also it thinks '...' is part of the semantic patch, so I put an 'int DOTDOTDOT' placeholder in its place and got rid of it with sed afterwards. I didn't convert drm_plane_init() since passing the varargs through would mean either cpp macros or va_list, and I figured we don't care about these legacy functions enough to warrant the extra pain. @@ typedef uint32_t; identifier dev, plane, possible_crtcs, funcs, formats, format_count, type; @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, unsigned long possible_crtcs, const struct drm_plane_funcs *funcs, const uint32_t *formats, unsigned int format_count, enum drm_plane_type type + ,const char *name, int DOTDOTDOT ) { ... } @@ identifier dev, plane, possible_crtcs, funcs, formats, format_count, type; @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, unsigned long possible_crtcs, const struct drm_plane_funcs *funcs, const uint32_t *formats, unsigned int format_count, enum drm_plane_type type + ,const char *name, int DOTDOTDOT ); @@ expression E1, E2, E3, E4, E5, E6, E7; @@ drm_universal_plane_init(E1, E2, E3, E4, E5, E6, E7 + ,NULL ) v2: Split crtc and plane changes apart Pass NUL for no-name instead of "" Leave drm_plane_init() alone v3: Add ', or NULL...' to @name kernel doc (Jani) Annotate the function with __printf() attribute (Jani) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1449670795-2853-1-git-send-email-ville.syrjala@linux.intel.com
2015-10-20drm: rcar-du: Fix plane state free in plane reset handlerLaurent Pinchart1-23/+22
The plane reset handler frees the plane state and allocates a new default state, but when doing so attempt to free the plane state using the base plane state pointer instead of casting it to the driver-specific state object that has been allocated. Fix it by using the rcar_du_plane_atomic_destroy_state() function to destroy the plane state instead of duplicating the code. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Thierry Reding <treding@nvidia.com>
2015-06-16drm: rcar-du: Use the drm atomic state duplication helpers for planesLaurent Pinchart1-5/+5
Ensure that the duplicate and destroy plane state operations will always be in sync with the DRM core implementation of the plane state by using the __drm_atomic_helper_plane_duplicate_state() and __drm_atomic_helper_plane_destroy_state() functions designed especially for this purpose. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2015-06-16drm: rcar-du: Fix crash with groups that have less than 9 planesLaurent Pinchart1-3/+2
Commit 917de180379d ("drm: rcar-du: Implement universal plane support") made the number of planes per group dynamic, but didn't update all loops over the planes array, resulting in out-of-bound accesses on DU instances that have an odd number of CRTCs (such as the R8A7790). Fix it. Fixes: 917de180379d ("drm: rcar-du: Implement universal plane support") Cc: stable@vger.kernel.org Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-05-25drm: rcar-du: Store the number of CRTCs per group in the group structureLaurent Pinchart1-4/+2
The number of CRTCs in a group is only used to implement plane initialization for now, but is also needed to implement pre-association of planes to CRTCs. Store it in the group structure instead of computing it on demand. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-05-25drm: rcar-du: Rename to_rcar_du_plane_state to to_rcar_plane_stateLaurent Pinchart1-8/+8
All other cast functions are named without using "du", make the plane state cast consistent with them. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-05-25drm: rcar-du: Embed rcar_du_planes structure into rcar_du_groupLaurent Pinchart1-2/+1
The rcar_du_planes structure contains a single field and is only instantiated in the rcar_du_group structure. Embed it directly and remove the rcar_du_planes structure. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-05-25drm: rcar-du: Move properties from rcar_du_planes to rcar_du_deviceLaurent Pinchart1-34/+12
The plane property objects are instantiated once per CRTC group, while they should be instantiated once globally for the device. Fix this and move them to the rcar_du_device structure. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-19drm: rcar-du: Fix framebuffer reference leak through plane stateLaurent Pinchart1-0/+3
Plane state duplication takes a reference to the framebuffer stored in the state, but state destroy doesn't release it. This causes a reference leak. Fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Fix race condition in hardware plane allocatorLaurent Pinchart1-154/+12
The plane allocator has been inherently racy since the beginning of the transition to atomic updates, as the allocator lock is released between free plane check (at .atomic_check() time) and the reservation (at .atomic_update() time). To fix it, create a new allocator solely based on the atomic plane states without keeping any external state and perform allocation in the .atomic_check() handler. The core idea is to replace the free planes bitmask with a collective knowledge based on the allocated hardware plane(s) for each KMS plane. The allocator then loops over all plane states to compute the free planes bitmask, allocates hardware planes based on that bitmask, and stores the result back in the plane states. For this to work we need to access the current state of planes not touched by the atomic update. To ensure that it won't be modified, we need to lock all planes using drm_atomic_get_plane_state(). This effectively serializes atomic updates from .atomic_check() up to completion, either when swapping the states if the check step has succeeded, or when freeing the states if the check step has failed. Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Move plane format to plane stateLaurent Pinchart1-46/+61
The format stored in the rcar_du_plane structure is part of the plane state. Move it to the rcar_du_plane_state structure and precompute it in the .atomic_check() handler. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Replace plane crtc and enabled fields by plane stateLaurent Pinchart1-12/+3
The crtc and enabled fields duplicates information stored in the plane state. Use the plane state instead and remove the fields. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Rework plane setup codeLaurent Pinchart1-22/+12
Now that the plane setup code isn't called outside of the plane implementation, it can be simplified by merging the rcar_du_plane_compute_base() and rcar_du_plane_update_base() functions. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Switch plane set_property to atomic helpersLaurent Pinchart1-51/+74
Allow setting up plane properties atomically using the plane set_property atomic helper. The properties are now stored in the plane state (requiring subclassing it) and applied when updating the planes. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Switch page flip to atomic helpersLaurent Pinchart1-3/+3
The atomic page flip helper implements the page flip operation using asynchronous commits. As the legacy page flip was the last CRTC operation that needed direct access to plane setup, the plane setup functions can now become private to the plane implementation. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Switch plane update to atomic helpersLaurent Pinchart1-2/+2
This removes the legacy plane update code. Wire up the default atomic check and atomic commit mode config helpers as needed by the plane update atomic helpers. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Remove private copy of plane size and positionLaurent Pinchart1-15/+10
The plane source and destination size and positions are stored in the plane state, and a private copy is kept in the rcar_du_plane objects. Remove the private copy as it just duplicates the state. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Wire up atomic state object scaffoldingLaurent Pinchart1-0/+4
Hook up the default .reset(), .atomic_duplicate_state() and .atomic_free_state() helpers to ensure that state objects are properly created and destroyed, and call drm_mode_config_reset() at init time to create the initial state objects. Framebuffer reference count also gets maintained automatically by the transitional helpers except for the legacy page flip operation. Maintain it explicitly there. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Handle primary plane config through atomic plane opsLaurent Pinchart1-5/+3
Use the new CRTC atomic transitional helpers drm_helper_crtc_mode_set() and drm_helper_crtc_mode_set_base() to implement the CRTC .mode_set and .mode_set_base operations. This delegates primary plane configuration to the plane .atomic_update and .atomic_disable operations, removing duplicate code from the CRTC implementation. There is now no code path available to the driver in which to drop the reference to the CRTC acquired in the .prepare() operation if an error then occurs. The driver thus now leaks a reference if an error occurs during mode set. So be it, this will be fixed in a further step of the atomic update transition. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Implement planes atomic operationsLaurent Pinchart1-47/+105
Implement the CRTC .atomic_begin() and .atomic_flush() operations, the plane .atomic_check(), .atomic_update() and operations, and use the transitional atomic helpers to implement the plane update and disable operations on top of the new atomic operations. The plane setup code can't be moved out of the CRTC start function completely yet, as the atomic code paths are not taken every time the CRTC needs to be started. This results in some code duplication that will be fixed after switching to atomic updates completely. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Fix hardware plane allocationLaurent Pinchart1-2/+2
The hardware plane allocator loops over all planes to find free candidates. However, instead of looping over the number of hardware planes, it loops over the number of software planes, which happens to be larger by one unit. This has no effect in practise as the extra plane is always cleared in the mask of free planes, but it should still be fixed for correctness. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2015-03-03drm: rcar-du: Implement universal plane supportLaurent Pinchart1-35/+30
Explicitly create the CRTC primary plane instead of relying on the core helpers to do so. This simplifies the plane logic by merging the KMS and software planes. Reject plane API operations on the primary planes for now, as that code will anyway be refactored when implementing support for atomic updates. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-12-23drm: rcar-du: Implement support for interlaced modesLaurent Pinchart1-3/+15
Accept interlaced modes on the VGA and HDMI connectors and configure the hardware accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-12-23drm: rcar-du: Configure pitch for chroma plane of multiplanar formatsLaurent Pinchart1-0/+2
The PnMWR register containing the plane stride must be programmed with correct stride values for both the luma and chroma planes when using a multiplanar format. Fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2014-09-15drm/rcar-du: Update copyright noticeLaurent Pinchart1-1/+1
The "Renesas Corporation" listed in the copyright notice doesn't exist. Replace it with "Renesas Electronics Corporation" and update the copyright years. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-12-02drm/rcar-du: Update plane pitch in .mode_set_base() operationLaurent Pinchart1-10/+11
When setting a new frame buffer with the mode set base operation the pitch value might change. Set the hardware plane pitch register at the same time as the plane base address in the rcar_du_plane_update_base() function to make sure the pitch value always matches the frame buffer. Cc: stable@vger.kernel.org Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-08-10drm/rcar-du: Add support for multiple groupsLaurent Pinchart1-2/+4
The R8A7790 DU has 3 CRTCs, split in two groups. Support them. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-08-10drm/rcar-du: Introduce CRTCs groupsLaurent Pinchart1-76/+79
The R8A7779 DU is split in per-CRTC resources (scan-out engine, blending unit, timings generator, ...) and device-global resources (start/stop control, planes, ...) shared between the two CRTCs. The R8A7790 introduced a third CRTC with its own set of global resources This would be modeled as two separate DU device instances if it wasn't for a handful or resources that are shared between the three CRTCs (mostly related to input and output routing). For this reason the R8A7790 DU must be modeled as a single device with three CRTCs, two sets of "semi-global" resources, and a few device-global resources. Introduce a new rcar_du_group driver-specific object, without any real counterpart in the DU documentation, that models those semi-global resources. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-08-10drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_*Laurent Pinchart1-2/+2
The functions initialize or register all planes, rename them accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-08-10drm/rcar-du: Clarify comment regarding plane Y source coordinateLaurent Pinchart1-3/+6
The R8A7790 DU documentation contains further information regarding the plane Y source coordinate. Update the comment accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
2013-06-27drm: Renesas R-Car Display Unit DRM driverLaurent Pinchart1-0/+507
The R-Car Display Unit (DU) DRM driver supports both superposition processors and all eight planes in RGB and YUV formats with alpha blending. Only VGA and LVDS encoders and connectors are currently supported. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Dave Airlie <airlied@redhat.com>