Commit graph

104 commits

Author SHA1 Message Date
Dave Airlie
cb2e77c1d5 Allwinner DRM changes for 4.12
Not any functional changes, but a lot of preliminary rework in order to
 support multiple display pipelines.
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJY5fHyAAoJEBx+YmzsjxAgnQwQAKsMoIzz8cWI6DByFVOo4IrB
 c8sTThSGh08EiLK05E8JVKedUX2w9Gn7GatwaCur0CSjjQr2evzOvhGjjAVdi2fS
 jDw5j8S4GY6XJMzSZyq2Q6cbshZJqNp5ZThqD9/xDbYOWM1YxOFzybIK/f0hDzcG
 k+qPKtTdXDGdlLfrV44ZIOim63jYD+Nv+C4RyrVny+W6Z3bRg6SyiotDNB3E3ToV
 8hM8nvFE8SWxmx/eWRcUbnH1YPVNjEU2Uw6l1OhBaovtHKL/dD61/OBZ/MGwr64o
 HsrWxlwbdQkv1FxR3NUfeRMCfhDKYyQgBuW8P0H1JlHWTov6lijcmq7L5lASw01j
 3FzNpZ1r8/wXncj0nwwXaPtnq81IL2ek4Af4E2p46gFJJ+SU5UMWI4C5KZflidzS
 Wlhg+3xiiAhmfQef2rCdkERJ/BHN9DyVeadGF+FDxJRyqhnY8fOYrTpxYlAikUSg
 hL3Eqy8v111eaORV+k7NBqjkvCMPKe+7yEiH65mAjt/l446FbLi5IEdIdxnR91Nt
 7kdbgpJqx5wZfRqJrfqUxd/td4GTGgWmSKfPcqs1j5azG52SB1T0+T5ztF0S9z1M
 zS41ixquxPBt4l7dMtYerHiYGVYUSyF2CHIgAJs3HI1jR/qs6W7EPk0kBANNPSVu
 +mT1QyeTAYaF9PZxlHvU
 =XlmY
 -----END PGP SIGNATURE-----

Merge tag 'sunxi-drm-for-4.12' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux into drm-next

Allwinner DRM changes for 4.12

Not any functional changes, but a lot of preliminary rework in order to
support multiple display pipelines.

* tag 'sunxi-drm-for-4.12' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux: (26 commits)
  MAINTAINERS: Add sun4i-drm git repo
  drm/sun4i: Pass pointer for underlying backend into layer init
  drm/sun4i: Pass pointers for associated backend and tcon into crtc init
  drm/sun4i: tv: Get tcon and backend pointers from associated crtc
  drm/sun4i: Use embedded tcon pointer to get the tcon's output port node
  drm/sun4i: Fix tcon channel 0 comment about backporch = backporch + hsync
  drm/sun4i: Fix TCON clock and regmap initialization sequence
  drm/sun4i: Grab reserved memory region
  drm/sun4i: Add backend and tcon pointers to sun4i_crtc
  drm/sun4i: Add backend pointer to sun4i_layer
  drm/sun4i: rgb: Pass tcon pointer when initializing RGB encoder
  drm/sun4i: tv: Switch to drm_of_find_possible_crtcs
  drm/sun4i: Drop hardcoded .possible_crtcs values from layers
  drm/sun4i: Drop primary layer pointer from sun4i_drv
  drm/sun4i: Initialize crtc from tcon bind function
  drm/sun4i: Move layers from sun4i_drv to sun4i_crtc
  drm/sun4i: Add end of list element for sun4i_layers_init's returned list
  drm/sun4i: Set drm_crtc.port to the underlying TCON's output port node
  drm/sun4i: Make sunxi_rgb2yuv_coef constant
  drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes
  ...
2017-04-20 13:19:34 +10:00
Rob Herring
ebc9446135 drm: convert drivers to use drm_of_find_panel_or_bridge
Similar to the previous commit, convert drivers open coding OF graph
parsing to use drm_of_find_panel_or_bridge instead.

This changes some error messages to debug messages (in the graph core).
Graph connections are often "no connects" depending on the particular
board, so we want to avoid spurious messages. Plus the kernel is not a
DT validator.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Archit Taneja <architt@codeaurora.org>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[seanpaul dropped rockchip changes since they're now obsolete]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
2017-04-06 17:00:27 -04:00
Daniel Vetter
d55f7e5d54 drm: Create DEFINE_DRM_GEM_CMA_FOPS and roll it out to drivers
Less code ftw.

This converts all drivers except the tinydrm helper module. That one
needs more work, since it gets the THIS_MODULE reference from
tinydrm.ko instead of the actual driver module like it should.
Probably needs a similar trick like I used here with generating the
entire struct with a macro.

Cc: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170308141257.12119-24-daniel.vetter@ffwll.ch
2017-03-14 14:38:34 +01:00
Chen-Yu Tsai
a0a68fb687 drm/sun4i: Pass pointer for underlying backend into layer init
sun4i_layer only controls the backend hardware block of the display
pipeline.

Pass pointers to the underlying backend in the layer init function,
instead of trying to fetch it from the drm_device structure. This
avoids the headache of trying to figure out which device the layers
actually belong to.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:22:22 +01:00
Chen-Yu Tsai
18c3b30083 drm/sun4i: Pass pointers for associated backend and tcon into crtc init
sun4i_crtc controls the backend and tcon hardware blocks of the display
pipeline.

Pass pointers to the underlying devices into the crtc init function,
instead of trying to fetch them from the drm_device structure. This
avoids the headache of trying to figure out which devices the crtc
is actually associated with.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:21:52 +01:00
Chen-Yu Tsai
279156a33c drm/sun4i: tv: Get tcon and backend pointers from associated crtc
The drm_encoder structure provides us with a pointer to the crtc
currently tied to the encoder. Subsequently we can extract the
tcon and backend pointers from our crtc structure, instead of
getting it directly from the sun4i_drv structure.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:19:59 +01:00
Chen-Yu Tsai
e4cdcb7cce drm/sun4i: Use embedded tcon pointer to get the tcon's output port node
A pointer to the underlying tcon of the crtc was added to the sun4i_crtc
structure in "drm/sun4i: Add backend and tcon pointers to sun4i_crtc".
However the crtc init function was still using the copy from sun4i_drv
to set drm_crtc.port. This was an oversight when the patches were
reordered.

Switch to using the embedded tcon pointer to get the tcon's ouptut port
and assign it to drm_crtc.port.

This makes it possible to remove the usage of sun4i_drv completely in
subsequent patches.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:19:45 +01:00
Chen-Yu Tsai
23a1cb11d9 drm/sun4i: Fix tcon channel 0 comment about backporch = backporch + hsync
The backporch programmed into the tcon registers is actually the
backporch + hsync length from the display timings, as indicated in
the interface timing diagrams found in the user manual of the A31
and A33 SoCs.

The comments for channel 0 mistakenly describe the discrepancy as
TCON backporch = frontporch + hsync.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:19:05 +01:00
Chen-Yu Tsai
4c7f16d14a drm/sun4i: Fix TCON clock and regmap initialization sequence
The TCON driver calls sun4i_tcon_init_regmap and sun4i_tcon_init_clocks
in its bind function. The former creates a regmap and writes to several
register to clear its configuration to a known default. The latter
initializes various clocks. This includes enabling the bus clock for
register access and creating the dotclock.

In order for the first step's writes to work, the bus clock must be
enabled which is done in the second step. but the dotclock's ops use
the regmap created in the first step.

Rearrange the function calls such that the clocks are initialized before
the regmap, and split out the dot clock creation to after the regmap is
initialized.

Fixes: 9026e0d122 ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-09 11:15:53 +01:00
Maxime Ripard
596afb6f05 drm/sun4i: Grab reserved memory region
Allow to provide an optional memory region to allocate from for our DRM
driver.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:24:02 +01:00
Chen-Yu Tsai
3c64fb3747 drm/sun4i: Add backend and tcon pointers to sun4i_crtc
sun4i_crtc controls the backend and tcon hardware blocks of the display
pipeline. Instead of doing so through the master drm structure, leave
pointers to the corresponding backend and tcon in itself.

Also drop the drm_device pointer, since it is no longer needed.

The next step forward would be to pass the pointers in through
sun4i_crtc_init as parameters. This would make it easier to support
multiple display pipelines layer on.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:24:01 +01:00
Chen-Yu Tsai
ace6c095ba drm/sun4i: Add backend pointer to sun4i_layer
sun4i_layer only controls the backend hardware block of the display
pipeline. Instead of getting a pointer to the underlying backend
through the drm_device structure, leave one in itself.

Also drop the drm_device pointer, since it is no longer needed.

The next step forward would be to pass the pointer in through
sun4i_layers_init as a parameter. This would make it easier to support
multiple display pipelines layer on.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:24 +01:00
Chen-Yu Tsai
b9c8506cb8 drm/sun4i: rgb: Pass tcon pointer when initializing RGB encoder
The RGB encoder represents channel 0 of the TCON. Instead of fetching
the pointer to its TCON from the main sun4i_drv structure, pass it in
as part of the init call, save it, and use it directly in the encoder
and connector callbacks.

We can also drop the otherwise unused sun4i_drv pointer.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:24 +01:00
Chen-Yu Tsai
78428d672c drm/sun4i: tv: Switch to drm_of_find_possible_crtcs
Now that the crtcs have their .port field set properly, we can use
drm_of_find_possible_crtcs to find the connected crtcs, instead of
hardcoding the first crtc as usable. The new code also defers binding
when the upstream crtc hasn't been registered yet.

This makes it easier to support multiple tcons/crtcs.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:24 +01:00
Chen-Yu Tsai
a5154a4d01 drm/sun4i: Drop hardcoded .possible_crtcs values from layers
To support multiple display pipelines, we would have multiple crtcs,
with one or more planes bound to them. Obviously having hardcoded
values for the drm_plane .possible_crtcs field is not going to work.

For primary and cursor planes, the value is set by
drm_crtc_init_with_planes. We just need to set it for overlay planes.

We also fix the value set for the RGB encoder, by referencing the
crtc set in sun4i_drv.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:23 +01:00
Chen-Yu Tsai
dcd215801b drm/sun4i: Drop primary layer pointer from sun4i_drv
The current layer init code keeps a pointer to the primary plane layer
in sun4i_drv. When we eventually support multiple display pipelines,
this would force us to keep track of primary planes for all crtcs. And
these pointers only get used at bind time.

Instead, have the crtc init code iterate through the returned layers
to find the primary and cursor layers. And drop the pointer from the
sun4i_drv structure.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:23 +01:00
Chen-Yu Tsai
46cce6dac3 drm/sun4i: Initialize crtc from tcon bind function
The tcon provides part of the functionality of the crtc, and also
provides the device node for the output port of the crtc. To be able
to use drm_of_find_possible_crtcs(), all crtc must be initialized before
any downstream encoders. The other part of the crtc is the display
backend.

The Rockchip DRM driver does this by first binding all vops, which is
their crtc, and this step also creates the crtc objects. Then all
remaining hardware components are bound. With the Allwinner display
pipeline, we have multiple components comprising the crtc, and varying
depths of the display pipeline. Since components are added with a depth
first search of the of_graph, we can initialize the crtc object within
the tcon bind function. Since the backend precedes the tcon, and the
backends cannot be muxed or switched around, we can be sure that the
associated backend is already initialized.

This patch also moves the crtc pointer from the main drm_device data to
the tcon device data. Besides the crtc callbacks, the crtc structure is
only used within the tcon driver to signal vblank events from its
interrupt handler.

As the crtc and layer bits are now called from the tcon bits, we must
move them from the sun4i-drm module to the sun4i-tcon module to avoid
circular dependencies between the two modules. This is because sun4i-drm
also calls into sun4i-tcon.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:23 +01:00
Chen-Yu Tsai
b3f266e428 drm/sun4i: Move layers from sun4i_drv to sun4i_crtc
This patch moves the sun4i_layers_init call from sun4i_drv_bind to
sun4i_crtc_init, and the layers pointer from struct sun4i_drv to
struct sun4i_crtc.

The layers are bound to a specific crtc, and they are not directly
used once initiated. They are used through their included drm_plane
structures.

Moving the layers into the crtc facilitates binding them to the crtc
explicitly, by setting the corresponding bit in their .possible_crtcs
fields right after the crtc is initialized. This is done in a later
patch.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:18:23 +01:00
Chen-Yu Tsai
2b2c22bf1c drm/sun4i: Add end of list element for sun4i_layers_init's returned list
The number of defined planes in sun4i_layer is unknown to other parts
of the sun4i drm driver. Since the return value of sun4i_layers_init
is a list of layers, make it return 1 more empty layer as an end of
list guard value.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:16 +01:00
Chen-Yu Tsai
7544860733 drm/sun4i: Set drm_crtc.port to the underlying TCON's output port node
The way drm_of_find_possible_crtcs works is it tries to match the
remote-endpoint of the given node's various endpoints to all the
crtc's .port field. Thus we need to set drm_crtc.port to the output
port node of the underlying TCON.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
a6fbffb030 drm/sun4i: Make sunxi_rgb2yuv_coef constant
sunxi_rgb2yuv_coef is a table of RGB-to-YUV conversion coefficients.
They are programmed into the hardware, and can be declared constant.

Reported-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
ea411fd2c8 drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes
sun4i_crtc_init can fail for a number of reasons. Instead of returning
a NULL pointer when it fails, pass back the encountered error using
ERR_PTR.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
903795d60f drm/sun4i: Save newly created layer in layers array in sun4i_layers_init
sun4i_layers_init allocates an array to store pointers to newly created
layers returned by sun4i_layer_init_one(), but fails to actually store
them. But it actually returns the empty array to unsuspecting users.

Save the pointers in the array, so that they may be used later.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
8a16469b74 drm/sun4i: Drop useless assignment in sun4i_layers_init
The assignment found in the main loop in sun4i_layers_init:

	struct sun4i_layer *layer = layers[i];

is useless as it gets overwritten by the next line:

	layer = sun4i_layer_init_one(drm, plane);

Drop the assignment.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
f43fbe7a59 drm/sun4i: Fix kcalloc element size in sun4i_layers_init
In sun4i_layers_init we are allocating an array of pointers to struct
sun4i_layer:

	layers = devm_kcalloc(drm->dev, ARRAY_SIZE(sun4i_backend_planes),
	                      sizeof(**layers), GFP_KERNEL);

The element size should be the size of an individual element of the
array. Change it to sizeof(*layers) to avoid wasting a lot of memory.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
92b300c4e6 drm/sun4i: Check return value of drm_vblank_init
drm_vblank_init can fail due to insufficient memory. Ignoring the error
and proceeding may cause the kernel to dereference an invalid pointer
when vblank is enabled.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:15 +01:00
Chen-Yu Tsai
9d56defb44 drm/sun4i: Fix up error path cleanup for master bind function
The master bind function calls numerous drm functions which initialize
underlying structures. It also tries to bind the various components
of the display pipeline, some of which may add additional drm objects.

This patch adds proper cleanup functions in the error path of the
master bind function.

This requires the patch "drm/sun4i: Move drm_mode_config_cleanup call
to main driver", which splits out drm_mode_config_cleanup from
sun4i_framebuffer_free so we can call it separately.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:14 +01:00
Chen-Yu Tsai
92caf9bede drm/sun4i: Move drm_mode_config_cleanup call to main driver
drm_mode_config_cleanup is the complement of drm_mode_config_init, which
is called in the bind function of sun4i_drv. drm_mode_config_cleanup
should be put in the unbind function to match.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-03-07 22:15:14 +01:00
Shawn Guo
50480a78e2 drm: sun4i: use vblank hooks in struct drm_crtc_funcs
The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1486458995-31018-20-git-send-email-shawnguo@kernel.org
2017-02-09 16:10:52 +08:00
Shawn Guo
967dd48417 drm: remove drm_vblank_no_hw_counter assignment from driver code
Core code already makes drm_driver.get_vblank_counter hook optional by
letting drm_vblank_no_hw_counter be the default implementation for the
function hook.  So the drm_vblank_no_hw_counter assignment in the driver
code becomes redundant and can be removed now.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mali DP Maintainers <malidp@foss.arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Eric Anholt <eric@anholt.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1486458995-31018-3-git-send-email-shawnguo@kernel.org
2017-02-07 21:43:55 +01:00
Gabriel Krisman Bertazi
e4563f6ba7 drm: Rely on mode_config data for fb_helper initialization
Instead of receiving the num_crts as a parameter, we can read it
directly from the mode_config structure.  I audited the drivers that
invoke this helper and I believe all of them initialize the mode_config
struct accordingly, prior to calling the fb_helper.

I used the following coccinelle hack to make this transformation, except
for the function headers and comment updates.  The first and second
rules are split because I couldn't find a way to remove the unused
temporary variables at the same time I removed the parameter.

// <smpl>
@r@
expression A,B,D,E;
identifier C;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)

@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)

@@
identifier r.C;
type T;
expression V;
@@
- T C;
<...
when != C
- C = V;
...>
// </smpl>

Changes since v1:
 - Rebased on top of the tip of drm-misc-next.
 - Remove mention to sti since a proper fix got merged.

Suggested-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170202162640.27261-1-krisman@collabora.co.uk
2017-02-02 19:12:00 +01:00
Dave Airlie
02a84c135e Allwinner DRM changes for 4.11
Just one minor fix.
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJYkFQBAAoJEBx+YmzsjxAgcP4QAKbh9vgqcucnnX5kG6K6oH98
 ZXrooKYHOcVghUqoMS1tgOCCWKsRrId41rX4kxhSMEEyMQgwt0MMAr1gexNE+n5R
 UNQDZ0cAjaIo9Mf2Ivwz3KO2k1k2kU5Q2vJlcUdHYHOgRPt35NRgznWayFXMiksN
 SbGYNdaoTeCOoUTL9gNATipUIIsLWBYKW8M7eCn2/0LzAr24KLh3l5hfQVdPEvBs
 H80IxRlDN0olPOuy3MRqVlVG92kHhBgTOomJRgGyecsUP8vxOWriha5yfMVb2EwM
 jjUz//WJkKoAnQb2CcgEPPTV2DOHvajkaoUI+abB/dpPAepi/W3pVVsD9uSMiBgY
 IFY1PmD/lAg6CbJfy13qB9vzzt1Huho1XdwFJLnKq8s3PuRIr9oIlPEzDKXkBZml
 wbDAgnThU8lW2nhOvHNp0qtIwD0yparBOOyCcn5wjCqUOPLlgvAYloiNcadGxDuv
 PTmJcZVJwdW4Fu0lB53S3BpkfK0hUg7+Om4oclTM5MkfyheINFTKRzcUDUw4Hmx5
 ekGiL52tlxeBY+DIXVLxCbfjMGIR9+On0obuwSTRKj2KzhI1Ias/WIzjJYGgzjWF
 tB4D3SqkecoC+uetSx7ClypZPKSUvVCGEDt775e6Q2eLEBoVajymiHGtTrh5Jg6Y
 eQDvde29f76IJu+0a5MC
 =SSQZ
 -----END PGP SIGNATURE-----

Merge tag 'sunxi-drm-for-4.11' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux into drm-next

Allwinner DRM changes for 4.11

Just one minor fix.

* tag 'sunxi-drm-for-4.11' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux:
  drm/sun4i: Fix a return value in case of error
2017-02-01 08:43:19 +10:00
Christophe JAILLET
0f0861e31e drm/sun4i: Fix a return value in case of error
If 'sun4i_backend_drm_format_to_layer()' does not return 0, then 'val' is
left unmodified.
As it is not initialized either, the return value can be anything.

It is likely that returning the error code was expected here.

As the only caller of 'sun4i_backend_update_layer_formats()' does not check
the return value, this fix is purely theorical.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-01-02 22:27:58 +01:00
Laurent Pinchart
3bb80f2495 drm: bridge: Link encoder and bridge in core code
Instead of linking encoders and bridges in every driver (and getting it
wrong half of the time, as many drivers forget to set the drm_bridge
encoder pointer), do so in core code. The drm_bridge_attach() function
needs the encoder and optional previous bridge to perform that task,
update all the callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Stefan Agner <stefan@agner.ch> # For DCU
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> # For atmel-hlcdc
Acked-by: Vincent Abriou <vincent.abriou@st.com> # For STI
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> # For sun4i
Acked-by: Xinliang Liu <z.liuxinliang@hisilicon.com> # For hisilicon
Acked-by: Jyri Sarha <jsarha@ti.com> # For tilcdc
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com
2016-12-18 16:31:45 +05:30
Ville Syrjälä
438b74a549 drm: Nuke fb->pixel_format
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-12-15 14:55:34 +02:00
Ville Syrjälä
353c859899 drm: Replace drm_format_plane_cpp() with fb->format->cpp[]
Replace drm_format_plane_cpp(fb->pixel_format) with just
fb->format->cpp[]. Avoids the expensive format info lookup.

@@
struct drm_framebuffer *a;
struct drm_framebuffer b;
expression E;
@@
(
- drm_format_plane_cpp(a->pixel_format, E)
+ a->format->cpp[E]
|
- drm_format_plane_cpp(b.pixel_format, E)
+ b.format->cpp[E]
)

@@
struct drm_plane_state *a;
struct drm_plane_state b;
expression E;
@@
(
- drm_format_plane_cpp(a->fb->pixel_format, E)
+ a->fb->format->cpp[E]
|
- drm_format_plane_cpp(b.fb->pixel_format, E)
+ b.fb->format->cpp[E]
)

@@
struct drm_framebuffer *a;
identifier T;
expression E;
@@
  T = a->pixel_format
<+...
- drm_format_plane_cpp(T, E)
+ a->format->cpp[E]
...+>

@@
struct drm_framebuffer b;
identifier T;
expression E;
@@
  T = b.pixel_format
<+...
- drm_format_plane_cpp(T, E)
+ b.format->cpp[E]
...+>

v2: Rerun spatch due to code changes

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1481751057-18123-1-git-send-email-ville.syrjala@linux.intel.com
2016-12-15 14:55:31 +02:00
Daniel Vetter
75e75cbd55 Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next
Backmerge v4.9-rc8 to get at

commit e94bd1736f
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Wed Nov 30 17:30:01 2016 +0900

drm: Don't call drm_for_each_crtc with a non-KMS driver

so I can apply Michel's follow-up patch.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-12-06 10:26:48 +01:00
Dave Airlie
f03ee46be9 Linux 4.9-rc8
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJYRIGyAAoJEHm+PkMAQRiG2ksH/jwMUT9j6glbwESxbn1YTqTM
 QcBT5AMc7D0wNuidQe0hWZMtG4RbC+4ZhxzZl2wPgA2gueJ+rBnyX7bgtA7ka8ka
 Fdc3u/Q1v38HPzf8iBnxcdCs40VgsoMLjFYCXrpOxuGDNKYzRd+Q8aI2TeGvzbyi
 X8+6oAWifBwo2oA06jfcuUncEWbyDDyK9aQksmfKOpjHdb26yELPEhsPOlds1g7E
 jYLnvUVnU2CoFaumta+rZQ0kzLdc4Ntu0wEao6WzJuQKsgoID+tS/6iudi8cUhDp
 YowGAVoOfr6rAJB0mwrDVfugpamaT3386XKyocdNsK0/jR60UIJ8x+WzvvSU+lY=
 =JTBj
 -----END PGP SIGNATURE-----

Backmerge tag 'v4.9-rc8' into drm-next

Linux 4.9-rc8

Daniel requested this so we could apply some follow on fixes cleanly to -next.
2016-12-05 17:11:48 +10:00
Laurent Pinchart
949f08862d drm: Make the connector .detect() callback optional
Many drivers (21 to be exact) create connectors that are always
connected (for instance to an LVDS or DSI panel). Instead of forcing
them to implement a dummy .detect() handler, make the callback optional
and consider the connector as always connected in that case.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Vincent Abriou <vincent.abriou@st.com>
Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
[seanpaul fixed small conflict in rcar-du/rcar_du_lvdscon.c]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
2016-12-01 10:05:53 -05:00
Dave Airlie
318313d1d4 Merge tag 'drm-misc-next-2016-11-16' of git://anongit.freedesktop.org/git/drm-misc into drm-next
Another pile of misc:
- Explicit fencing for atomic! Big thanks to Gustavo, Sean, Rob 3x, Brian
  and anyone else I've forgotten to make this happen.
- roll out fbdev helper ops to drivers (Stefan Christ)
- last bits of drm_crtc split-up&kerneldoc
- some drm_irq.c crtc functions cleanup
- prepare_fb helper for cma, works correctly with explicit fencing (Marek
  Vasut)
- misc small patches all over

* tag 'drm-misc-next-2016-11-16' of git://anongit.freedesktop.org/git/drm-misc: (51 commits)
  drm/fence: add out-fences support
  drm/fence: add fence timeline to drm_crtc
  drm/fence: add in-fences support
  drm/bridge: analogix_dp: return error if transfer none byte
  drm: drm_irq.h header cleanup
  drm/irq: Unexport drm_vblank_on/off
  drm/irq: Unexport drm_vblank_count
  drm/irq: Make drm_vblank_pre/post_modeset internal
  drm/nouveau: Use drm_crtc_vblank_off/on
  drm/amdgpu: Use drm_crtc_vblank_on/off for dce6
  drm/color: document NULL values and default settings better
  drm: Drop externs from drm_crtc.h
  drm: Move tile group code into drm_connector.c
  drm: Extract drm_mode_config.[hc]
  Revert "drm: Add aspect ratio parsing in DRM layer"
  Revert "drm: Add and handle new aspect ratios in DRM layer"
  drm/print: Move kerneldoc next to definition
  drm: Consolidate dumb buffer docs
  drm: Clean up kerneldoc for struct drm_driver
  drm: Extract drm_drv.h
  ...
2016-11-17 08:02:46 +10:00
Dave Airlie
4473904ccd sun4i-drm changes for 4.10
Support for the Allwinner A31 SoC display engine using the sun4i-drm
 driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJYK3v7AAoJEBx+YmzsjxAgc6oQAJlonN7vkVqe05wLynl0xTLh
 oGVKSskd1FR6oYncZAIFC6ZpTY7+j0NogfXa90lESCuOyrNt6gUnngiUeKD7ZBMS
 g+BgIjUbmPwa0QRKfJl7QkNs4EK+rMMOi5t9ku+pf3mbId3FIyV7IV7jeJrqrxy7
 i5Q+2bXK3NikQetjj7KvVzSAGx2CUa8h8gvIU1ntgs/2blPdVV3KFBSxS63UjuNr
 oOgkR1LJyojKOd2MKORvbF6WH43q7gsL6IRMsnHLs497HhRK6fSDruyVs5E7ODkR
 0RHwM5RUbVj4T8JHyZ0IAyunv26nU9dOVDAznmMdw8pA3E9EjFTob8SvwWtlPl6M
 h37+dBtvjP3SvL4vDL5UJNI7PZuG0Z6MwGJJkBtfJN2A0JL8THbOjBSP67md59vr
 Nj1hIrqxteAHxH9OfaW8R3Lg2JIUOaWCI4u0q4G+pn626kNsOeewBuJgoeqw2MS4
 PZoN5U6wxQQbSqWDAYCiasljyEDloNuCLgSF1hesKA8ezyV9ATzJGy0MfGqQpo3W
 hKiYEmiKLra+ZcHzZJpZD7I5iu0yyF4qaXPS1H65Ryc1R3ro1xe+AR5BcYQYALlU
 c7p/MpDoVO8vUdQk1utl8QbS9LqADgE72yKqE7T7a5SPGmMkImofNM3ndc3DDl2B
 pQEnH5CRwBADyzaRZBWu
 =fERq
 -----END PGP SIGNATURE-----

Merge tag 'sunxi-drm-for-4.10' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux into drm-next

sun4i-drm changes for 4.10

Support for the Allwinner A31 SoC display engine using the sun4i-drm
driver.

* tag 'sunxi-drm-for-4.10' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux:
  drm/sun4i: Add a few formats
  drm/sun4i: Add compatible strings for A31/A31s display pipelines
  drm/sun4i: Add compatible string for A31/A31s TCON (timing controller)
  drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure
  drm/sun4i: sun6i-drc: Support DRC on A31 and A31s
2016-11-16 09:39:55 +10:00
Julia Lawall
dfeb693d5a drm/sun4i: constify component_ops structures
These component_ops structures are only used as the second argument to
component_add and component_del, which are declared as const, so the
structures can be declared as const as well.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@

static struct component_ops i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@

component_add(e1,&i@p)

@ok2@
identifier r.i;
expression e1;
position p;
@@

component_del(e1, &i@p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct component_ops e;
@@

e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@

static
+const
 struct component_ops i = { ... };
// </smpl>

The result of the size command before the change is (arm):

   text       data         bss     dec      hex filename
   5266        236           8    5510     1586 sun4i_backend.o
   6393        236           8    6637     19ed sun4i_tcon.o
   3700        368           8    4076      fec sun4i_tv.o
   1668        108           0    1776      6f0 sun6i_drc.o

and after the change:

   text       data         bss     dec     hex filename
   5274        228           8    5510    1586 sun4i_backend.o
   6401        228           8    6637    19ed sun4i_tcon.o
   3708        360           8    4076     fec sun4i_tv.o
   1676        100           0    1776     6f0 sun6i_drc.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1478971198-3659-1-git-send-email-Julia.Lawall@lip6.fr
2016-11-13 11:42:48 +01:00
Christophe JAILLET
4db069a2bf drm/sun4i: Propagate error to the caller
If 'sun4i_layers_init()' returns an error, propagate it instead of
returning -EINVAL unconditionally.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-11-07 16:09:35 +01:00
Maxime Ripard
47d7fbb32c drm/sun4i: Add a few formats
The planes can do more than what was previously exposed. Add support for
them.

Since we still have the issue that the primary plane cannot have any alpha
component, we will expose only the non-alpha formats in the primary
formats, and the alpha formats will be exposed in the overlays.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
2016-11-02 19:37:37 +01:00
Christophe JAILLET
6c08d7ab23 drm/sun4i: Fix error handling
'sun4i_layers_init()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-11-02 18:56:46 +01:00
Jani Nikula
55edf41b69 drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs
If we define drm_compat_ioctl NULL on CONFIG_COMPAT=n, we don't have to
check for the config everywhere.

Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1478014844-27454-1-git-send-email-jani.nikula@intel.com
2016-11-02 11:33:47 -04:00
Russell King
97ac0e47ae drm: convert DT component matching to component_match_add_release()
Convert DT component matching to use component_match_add_release().

Acked-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/E1bwo6l-0005Io-Q1@rmk-PC.armlinux.org.uk
2016-10-25 11:52:38 -04:00
Chen-Yu Tsai
49c440e87c drm/sun4i: Add compatible strings for A31/A31s display pipelines
The A31's display pipeline has 2 frontends, 2 backends, and 2 TCONs. It
also has new display enhancement blocks, such as the DRC (Dynamic Range
Controller), the DEU (Display Enhancement Unit), and the CMU (Color
Management Unit). It supports HDMI, MIPI DSI, and 2 LCD/LVDS channels.

The A31s display pipeline is almost the same, just without MIPI DSI.
Only the TCON seems to be different, due to the missing mux for MIPI
DSI.

Add compatible strings for both of them.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-10-20 17:59:56 +02:00
Chen-Yu Tsai
93a5ec14da drm/sun4i: Add compatible string for A31/A31s TCON (timing controller)
The A31 TCON has mux controls for how TCON outputs are routed to the
HDMI and MIPI DSI blocks.

Since the A31s does not have MIPI DSI, it only has a mux for the HDMI
controller input.

This patch only adds support for the compatible strings. Actual support
for the mux controls should be added with HDMI and MIPI DSI support.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-10-20 17:59:29 +02:00
Chen-Yu Tsai
91ea2f29cb drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure
We already have some differences between the 2 supported SoCs.
More will be added as we support other SoCs. To avoid bloating
the probe function with even more conditionals, move the quirks
to a separate data structure that's tied to the compatible string.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-10-20 17:58:33 +02:00