Add DRM for stih4xx platforms
Subsystems (4)
cover Add DRM for stih4xx platforms
This series of patches add the support of DRM/KMS drivers for STMicroelectronics chipsets stih416 and stih407.
Hardware is split in two main blocks: Compositor and TVout. Each of them includes specific hardware IPs and the display timing are controlled by a specific Video Timing Generator hardware IP (VTG).
Compositor is made of the follow hardware IPs:
- GDP (Generic Display Pipeline) which is an entry point for graphic (RGB) buffers
- VDP (Video Diplay Pipeline) which is an entry point for video (YUV) buffers
- HQVDP (High Quality Video Display Processor) that supports scaling, deinterlacing and some miscellaneous image quality improvements. It fetches the Video decoded buffers from memory, processes them and pushes them to the Compositor through a HW dedicated bus.
- Mixer is responsible of mixing all the entries depending of their respective z-order and layout
TVout is divided in 3 parts:
- HDMI to generate HDMI signals, depending of chipset version HDMI phy can change.
- HDA to generate signals for HD analog TV
- VIP to control/switch data path coming from Compositor
On stih416 compositor and Tvout are on different dies so a Video Trafic Advance inter-die Communication mechanism (VTAC) is needed.
+---------------------------------------------+ +----------------------------------------+ | +-------------------------------+ +----+ | | +----+ +--------------------------+ | | | | | | | | | | | +---------+ +----+ | | | | +----+ +------+ | | | | | | | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | | | | | | | +----+ | | | | +----+ |Mixer |--|-->| | | | | |---|->| switcher| | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | |---->|HDA | | | | | +------+ | |VTAC|========>|VTAC| | +---------+ +----+ | | | | | | | | | | | | | | | | Compositor | | | | | | | | TVout | | | +-------------------------------+ | | | | | | +--------------------------+ | | ^ | | | | | | ^ | | | | | | | | | | | | +--------------+ | | | | | | +-------------+ | | | VTG (master) |----->| | | | | |----->| VTG (slave) | | | +--------------+ +----+ | | +----+ +-------------+ | |Digital die | | Analog Die| +---------------------------------------------+ +----------------------------------------+
On stih407 Compositor and Tvout are on the same die
+-----------------------------------------------------------------+ | +-------------------------------+ +--------------------------+ | | | | | +---------+ +----+ | | | | +----+ +------+ | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | +----+ | | | | +----+ |Mixer |--|--|->| switcher| | | | | +----+ +-----+ | | | | | | +----+ | | | | |VDP +-->+HQVDP+--->| | | | | |---->|HDA | | | | | +----+ +-----+ +------+ | | +---------+ +----+ | | | | | | | | | | Compositor | | TVout | | | +-------------------------------+ +--------------------------+ | | ^ ^ | | | | | | +--------------+ | | | VTG | | | +--------------+ | |Digital die | +-----------------------------------------------------------------+
In addition of the drivers for the IPs listed before a thin I2C driver (hdmiddc) is used by HDMI driver to retrieve EDID for monitor.
To unify interfaces of GDP and VDP we create a "layer" interface called by compositor to control both GPD and VDP.
Hardware have memory contraints (alignment, contiguous) so we use CMA drm helpers functions to allocate frame buffer.
File naming convention is:
- sti_* for IPs drivers
- sti_drm_* for drm functions implementation.
Benjamin Gaignard (18):
drm: sti: add bindings for DRM driver
drm: sti: add VTG driver
drm: sti: add VTAC drivers
drm: sti: add HDMI driver
drm: sti: add I2C client driver for HDMI
drm: sti: add HDA driver
drm: sti: add TVOut driver
drm: sti: add sti layer interface definition
drm: sti: add GDP layer
drm: sti: add VID layer
drm: sti: add Mixer
drm: sti: add Compositor
drm: sti: add debug to GDP
drm: sti: add debug to VID
drm: sti: add debug to TVout
drm: sti: add debug to mixer
drm: sti: Add DRM driver itself
drm: sti: add HQVDP driver
Vincent Abriou (1):
drm: sti: rename mixer registers to be main/aux independent
.../devicetree/bindings/gpu/st,stih4xx.txt | 177 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 26 + drivers/gpu/drm/sti/Makefile | 23 + drivers/gpu/drm/sti/sti_compositor.c | 189 ++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++ drivers/gpu/drm/sti/sti_ddc.c | 56 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 + drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 + drivers/gpu/drm/sti/sti_drm_drv.c | 484 +++++++++ drivers/gpu/drm/sti/sti_drm_drv.h | 48 + drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 + drivers/gpu/drm/sti/sti_drm_plane.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 + drivers/gpu/drm/sti/sti_gdp.c | 726 +++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 75 ++ drivers/gpu/drm/sti/sti_hda.c | 826 +++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 1045 +++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 198 ++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 ++++ drivers/gpu/drm/sti/sti_hqvdp.c | 1089 ++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 + drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 +++++++ drivers/gpu/drm/sti/sti_layer.c | 324 ++++++ drivers/gpu/drm/sti/sti_layer.h | 116 +++ drivers/gpu/drm/sti/sti_mixer.c | 405 ++++++++ drivers/gpu/drm/sti/sti_mixer.h | 54 + drivers/gpu/drm/sti/sti_tvout.c | 863 ++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 ++ drivers/gpu/drm/sti/sti_vid.c | 259 +++++ drivers/gpu/drm/sti/sti_vid.h | 34 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 +++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 + drivers/gpu/drm/sti/sti_vtg.c | 438 ++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 + drivers/gpu/drm/sti/sti_vtg_utils.c | 99 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 29 + 44 files changed, 10303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_ddc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h create mode 100644 drivers/gpu/drm/sti/sti_hda.c create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c create mode 100644 drivers/gpu/drm/sti/sti_layer.h create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h
Signature · 1 line
1.9.0
PATCH 1/19 drm: sti: add bindings for DRM driver
Add DRM/KMS driver bindings documentation.
Describe the required properties for each of the hardware IPs drivers.
--- .../devicetree/bindings/gpu/st,stih4xx.txt | 177 +++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt
Documentation/devicetree/bindings/gpu/st,stih4xx.txt new file +177 -0
@@ -0,0 +1,177 @@ +STMicroelectronics stih4xx platforms + +- sti-compositor: frame compositor engine + Required properties: + - compatible: "st,stih<chip>-compositor" + - reg: Physical base address of the IP registers and length of memory mapped region. + - clocks: from common clock binding: handle hardware IP needed clocks, the + number of clocks may depend of the SoC type. + See ../clocks/clock-bindings.txt for details. + - clock-names: names of the clocks listed in clocks property in the same + order. + - resets: resets to be used by the device + See ../reset/reset.txt for details. + - reset-names: names of the resets listed in resets property in the same + order. + +- sti-vtac: video timing advanced inter dye communication Rx and TX + Required properties: + - compatible: "st,stih<chip>-vtac-rx" or "st,stih<chip>-vtac-tx" + - reg: Physical base address of the IP registers and length of memory mapped region. + - reg-names: names of the mapped memory regions listed in regs property in + the same order. + - clocks: from common clock binding: handle hardware IP needed clocks, the + number of clocks may depend of the SoC type. + See ../clocks/clock-bindings.txt for details. + - clock-names: names of the clocks listed in clocks property in the same + order. + - vtac-rx-aux: Must be set to indicated that the device is dedicated to + auxillary data path if not the device is used for main data path. + - vtac-tx-aux: Must be set to indicated that the device is dedicated to + auxillary data path if not the device is used for main data path. + +- sti-vtg: video timing generator + Required properties: + - compatible: "st,stih<chip>-vtg" + - reg: Physical base address of the IP registers and length of memory mapped region. + - reg-names: names of the mapped memory regions listed in regs property in + the same order. + - interrupts : VTG interrupt number to the CPU. + - interrupt-names: name of the interrupts listed in interrupts property in + the same order. + - vtg-aux: Must be set to indicated that the device is dedicated to + auxillary data path if not the device is used for main data path. + +- sti-tvout: video out hardware block + Required properties: + - compatible: "st,stih<chip>-tvout" + - reg: Physical base address of the IP registers and length of memory mapped region. + - reg-names: names of the mapped memory regions listed in regs property in + the same order. + - resets: resets to be used by the device + See ../reset/reset.txt for details. + - reset-names: names of the resets listed in resets property in the same + order. + - ranges: to allow probing of subdevices + +- sti-hdmi: hdmi output block + Required properties: + - compatible: "st,stih<chip>-hdmi"; + - reg: Physical base address of the IP registers and length of memory mapped region. + - reg-names: names of the mapped memory regions listed in regs property in + the same order. + - interrupts : HDMI interrupt number to the CPU. + - interrupt-names: name of the interrupts listed in interrupts property in + the same order + - clocks: from common clock binding: handle hardware IP needed clocks, the + number of clocks may depend of the SoC type. + - clock-names: names of the clocks listed in clocks property in the same + order. + - hdmi,hpd-gpio: gpio id to detect if an hdmi cable is plugged or not. + +sti-hda: + Required properties: + - compatible: "st,stih<chip>-hda" + - reg: Physical base address of the IP registers and length of memory mapped region. + - reg-names: names of the mapped memory regions listed in regs property in + the same order. + - clocks: from common clock binding: handle hardware IP needed clocks, the + number of clocks may depend of the SoC type. + See ../clocks/clock-bindings.txt for details. + - clock-names: names of the clocks listed in clocks property in the same + order. + +Example: + +/ { + ... + + sti-compositor@fd340000 { + compatible = "st,stih416-compositor"; + reg = <0xfd340000 0x1000>; + clock-names = "compo_main", "compo_aux", + "pix_main", "pix_aux"; + clocks = <&CLK_M_A2_DIV1 CLK_M_COMPO_MAIN>, <&CLK_M_A2_DIV1 CLK_M_COMPO_AUX>, + <&CLOCKGEN_C_VCC CLK_S_PIX_MAIN>, <&CLOCKGEN_C_VCC CLK_S_PIX_AUX>; + reset-names = "compo-main", "compo-aux"; + resets = <&softreset STIH416_COMPO_M_SOFTRESET>, <&softreset STIH416_COMPO_A_SOFTRESET>; + }; + + sti-vtac-rx-main@fee82800 { + compatible = "st,stih416-vtac-rx"; + reg = <0xfee82800 0x200>; + clock-names = "vtac_main_phy"; + clocks = <&CLK_M_A2_DIV0 CLK_M_VTAC_MAIN_PHY>; + }; + + sti-vtac-rx-aux@fee82a00 { + compatible = "st,stih416-vtac-rx"; + reg = <0xfee82a00 0x200>; + clock-names = "vtac_aux_phy"; + clocks = <&CLK_M_A2_DIV0 CLK_M_VTAC_AUX_PHY>; + vtac-rx-aux; + }; + + sti-vtac-tx-main@fd349000 { + compatible = "st,stih416-vtac-tx"; + reg = <0xfd349000 0x200>, <0xfd320000 0x10000>; + reg-names = "vtac-tx", "vtac-phy"; + clock-names = "vtac_tx_phy"; + clocks = <&CLK_S_A1_HS CLK_S_VTAC_TX_PHY>; + }; + + sti-vtac-tx-aux@fd349200 { + compatible = "st,stih416-vtac-tx"; + reg = <0xfd349200 0x200>, <0xfd320000 0x10000>; + reg-names = "vtac-tx", "vtac-phy"; + clock-names = "vtac_tx_phy"; + clocks = <&CLK_S_A1_HS CLK_S_VTAC_TX_PHY>; + vtac-tx-aux; + }; + + sti-vtg-main@fd348000 { + compatible = "st,stih416-vtg"; + reg = <0xfd348000 0x400>, <0xfe85A800 0x300>; + reg-names = "master", "slave"; + interrupts = <GIC_SPI 175 IRQ_TYPE_NONE>; + interrupt-names = "synchro_irq"; + }; + + sti-vtg-aux@fd348400 { + compatible = "st,stih416-vtg"; + reg = <0xfd348400 0x400>, <0xfe858200 0x300>; + reg-names = "master", "slave"; + interrupts = <GIC_SPI 176 IRQ_TYPE_NONE>; + interrupt-names = "synchro_irq"; + vtg-aux; + }; + + sti-tvout@fe000000 { + compatible = "st,stih416-tvout"; + reg = <0xfe000000 0x1000>, <0xfe85a000 0x400>, <0xfe830000 0x10000>; + reg-names = "tvout-reg1", "hda-reg", "syscfg"; + reset-names = "tvout"; + resets = <&softreset STIH416_HDTVOUT_SOFTRESET>; + ranges; + + sti-hdmi@fe85c000 { + compatible = "st,stih416-hdmi"; + reg = <0xfe85c000 0x1000>, <0xfe830000 0x10000>; + reg-names = "hdmi-reg", "syscfg"; + interrupts = <GIC_SPI 173 IRQ_TYPE_NONE>; + interrupt-names = "hdmi_irq"; + clock-names = "hdmi_pix", "hdmi_tmds", "hdmi_phy", "hdmi_audio"; + clocks = <&CLOCKGEN_C_VCC CLK_S_PIX_HDMI>, <&CLOCKGEN_C_VCC CLK_S_TMDS_HDMI>, <&CLOCKGEN_C_VCC CLK_S_HDMI_REJECT_PLL>, <&CLOCKGEN_B1 CLK_S_PCM_0>; + hdmi,hpd-gpio = <&PIO2 5>; + }; + + sti-hda@fe85a000 { + compatible = "st,stih416-hda"; + reg = <0xfe85a000 0x400>, <0xfe83085c 0x4>; + reg-names = "hda-reg", "video-dacs-ctrl"; + clock-names = "hda_pix", "hda_hddac"; + clocks = <&CLOCKGEN_C_VCC CLK_S_PIX_HD>, <&CLOCKGEN_C_VCC CLK_S_HDDAC>; + }; + }; + ... +};
Signature · 1 line
1.9.0
PATCH 2/19 drm: sti: add VTG driver
In reply to Benjamin GaignardVideo Time Generator drivers are used to synchronize the compositor
and tvout hardware IPs by providing line count, sample count,
synchronization signals (HSYNC, VSYNC) and top and bottom fields indication. VTG are used by pair for each data path (main or auxiliary): one for master and one for slave.
--- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 11 + drivers/gpu/drm/sti/Makefile | 3 + drivers/gpu/drm/sti/sti_vtg.c | 430 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 ++ drivers/gpu/drm/sti/sti_vtg_utils.c | 99 +++++++++ drivers/gpu/drm/sti/sti_vtg_utils.h | 26 +++ 8 files changed, 592 insertions(+) create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h
drivers/gpu/drm/Kconfig +2 -0
@@ -201,3 +201,5 @@ source "drivers/gpu/drm/tegra/Kconfig" source "drivers/gpu/drm/panel/Kconfig" source "drivers/gpu/drm/bridge/Kconfig" + +source "drivers/gpu/drm/sti/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_DRM_QXL) += qxl/ obj-$(CONFIG_DRM_BOCHS) += bochs/ obj-$(CONFIG_DRM_MSM) += msm/ obj-$(CONFIG_DRM_TEGRA) += tegra/ +obj-$(CONFIG_DRM_STI) += sti/ obj-y += i2c/ obj-y += panel/ obj-y += bridge/
drivers/gpu/drm/sti/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +config DRM_STI + tristate "DRM Support for STMicroelectronics SoC stiH41x Series" + depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) + help + Choose this option to enable DRM on STM stiH41x chipset + +config VTG_STI + tristate "Video Timing Generator for STMicroelectronics SoC stiH41x Series" + depends on DRM_STI + help + Choose this option to enable VTG on STM stiH41x chipset
drivers/gpu/drm/sti/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +ccflags-y := -Iinclude/drm + +obj-$(CONFIG_VTG_STI) += sti_vtg.o sti_vtg_utils.o
drivers/gpu/drm/sti/sti_vtg.c new file +430 -0
430 lines not on this page · raw message
drivers/gpu/drm/sti/sti_vtg.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_VTG_H_ +#define _STI_VTG_H_ + +#include <linux/platform_device.h> +#include <drm/drmP.h> + +extern struct device *vtg_main; +extern struct device *vtg_aux; + +int vtg_set_config (struct device *dev,const struct drm_display_mode *mode); +int vtg_register_client (struct device *dev,struct notifier_block *nb); +int vtg_unregister_client (struct device *dev,struct notifier_block *nb); + +#endif
drivers/gpu/drm/sti/sti_vtg_utils.c new file +99 -0
99 lines not on this page · raw message
drivers/gpu/drm/sti/sti_vtg_utils.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_VTG_UTILS_H_ +#define _STI_VTG_UTILS_H_ + +#include <drm/drmP.h> + +#define VTG_MAIN 0 +#define VTG_AUX 1 + +#define VTG_VBLANK_EVENT 1 + +int sti_vtg_setconfig (int main_aux,const struct drm_display_mode *mode); +int sti_vtg_register_client (int main_aux,struct notifier_block *nb); +int sti_vtg_unregister_client (int main_aux,struct notifier_block *nb); + +u32 sti_vtg_get_line_number (struct drm_display_mode mode,int y); +u32 sti_vtg_get_pixel_number (struct drm_display_mode mode,int x); + +#endif
Signature · 1 line
1.9.0
PATCH 3/19 drm: sti: add VTAC drivers
In reply to Benjamin GaignardVideo Trafic Advance Communication Rx and Tx drivers are designed for inter-die communication.
Both Tx and Rx must share the same configuration to communicate that is why vtac_mode[] is shared in sti_vtac_utils.h.
--- drivers/gpu/drm/sti/Kconfig | 6 ++ drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 ++++++++++++ 5 files changed, 351 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h
drivers/gpu/drm/sti/Kconfig +6 -0
@@ -4,6 +4,12 @@ config DRM_STI help Choose this option to enable DRM on STM stiH41x chipset +config VTAC_STI + tristate "Video Trafic Advance Communication Rx and Tx for STMicroelectronics SoC stiH41x Series" + depends on DRM_STI + help + Choose this option to enable VTAC on STM stiH41x chipset + config VTG_STI tristate "Video Timing Generator for STMicroelectronics SoC stiH41x Series" depends on DRM_STI
drivers/gpu/drm/sti/Makefile +1 -0
@@ -1,3 +1,4 @@ ccflags-y := -Iinclude/drm +obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.o obj-$(CONFIG_VTG_STI) += sti_vtg.o sti_vtg_utils.o
drivers/gpu/drm/sti/sti_vtac_rx.c new file +140 -0
140 lines not on this page · raw message
drivers/gpu/drm/sti/sti_vtac_tx.c new file +152 -0
152 lines not on this page · raw message
drivers/gpu/drm/sti/sti_vtac_utils.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 4/19 drm: sti: add HDMI driver
In reply to Benjamin GaignardAdd driver for HDMI ouput
--- drivers/gpu/drm/sti/Makefile | 5 + drivers/gpu/drm/sti/sti_hdmi.c | 503 +++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 195 +++++++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 +++++++++++++ 5 files changed, 1325 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c
drivers/gpu/drm/sti/Makefile +5 -0
@@ -1,4 +1,9 @@ ccflags-y := -Iinclude/drm +stidrm-y := sti_hdmi.o \ + sti_hdmi_tx3g0c55phy.o \ + sti_hdmi_tx3g4c28phy.o + +obj-$(CONFIG_DRM_STI) += stidrm.o obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.o obj-$(CONFIG_VTG_STI) += sti_vtg.o sti_vtg_utils.o
drivers/gpu/drm/sti/sti_hdmi.c new file +503 -0
503 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hdmi.h new file +195 -0
195 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c new file +398 -0
398 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c new file +224 -0
224 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [PATCH v1 04/19] drm: sti: add HDMI driver
Quoted 4 lines · Benjamin Gaignard
drivers/gpu/drm/sti/sti_hdmi.c new file +4
-0+/* +* Attach the I2C ddc client to allow hdmi i2c communication +* +* @ddc: i2c client
drivers/gpu/drm/sti/sti_hdmi.c line 348
Quoted 10 lines
drivers/gpu/drm/sti/sti_hdmi.c new file +10
-0+*/ +static struct i2c_client *hdmi_ddc; +void sti_hdmi_attach_ddc_client (struct i2c_client *ddc) +{ +DRM_DEBUG_DRIVER ("\n" ); + +if (ddc) + hdmi_ddc = ddc; +} +
you should have a look at the 'componentized device' support (ie drivers/base/component.c) for collecting up all the sub-devices you need. Gets rid of all these global ptrs. Probably want to do that before posting v2..
BR,
-R
PATCH 5/19 drm: sti: add I2C client driver for HDMI
In reply to Benjamin GaignardAdd I2C client driver to retrieve EDID.
--- drivers/gpu/drm/sti/Makefile | 3 ++- drivers/gpu/drm/sti/sti_ddc.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/sti/sti_ddc.c
drivers/gpu/drm/sti/Makefile +2 -1
@@ -2,7 +2,8 @@ ccflags-y := -Iinclude/drm stidrm-y := sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \ - sti_hdmi_tx3g4c28phy.o + sti_hdmi_tx3g4c28phy.o \ + sti_ddc.o obj-$(CONFIG_DRM_STI) += stidrm.o obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.o
drivers/gpu/drm/sti/sti_ddc.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 6/19 drm: sti: add HDA driver
In reply to Benjamin GaignardAdd driver to support analog TV ouput.
--- drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_hda.c | 453 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 454 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_hda.c
drivers/gpu/drm/sti/Makefile +1 -0
@@ -3,6 +3,7 @@ ccflags-y := -Iinclude/drm stidrm-y := sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \ sti_hdmi_tx3g4c28phy.o \ + sti_hda.o \ sti_ddc.o obj-$(CONFIG_DRM_STI) += stidrm.o
drivers/gpu/drm/sti/sti_hda.c new file +453 -0
453 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 7/19 drm: sti: add TVOut driver
In reply to Benjamin GaignardTVout hardware block is responsible to dispatch the data flow coming from compositor block to any of the output (HDMI or Analog TV). It control when output are start/stop and configure according the require flow path.
--- drivers/gpu/drm/sti/Makefile | 4 +- drivers/gpu/drm/sti/sti_hda.c | 373 ++++++++++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 542 +++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 3 + drivers/gpu/drm/sti/sti_tvout.c | 682 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 +++++++ 7 files changed, 1722 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h
drivers/gpu/drm/sti/Makefile +3 -1
@@ -1,6 +1,8 @@ ccflags-y := -Iinclude/drm -stidrm-y := sti_hdmi.o \ +stidrm-y := \ + sti_tvout.o \ + sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \ sti_hdmi_tx3g4c28phy.o \ sti_hda.o \
drivers/gpu/drm/sti/sti_hda.c +373 -0
385 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hda.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Copyright (C) STMicroelectronics SA 2014 +* Authors: Fabien Dessenne <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_HDA_H_ +#define _STI_HDA_H_ + +#include "sti_tvout.h" + +struct sti_tvout_connector *sti_hda_create (struct sti_tvout *tvout); + +#endif
drivers/gpu/drm/sti/sti_hdmi.c +542 -0
548 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hdmi.h +3 -0
@@ -11,6 +11,8 @@#include <drm/drmP.h> +#include "sti_tvout.h" +/* HDMI v2.9 macro cell */ #define HDMI_CFG 0x0000#define HDMI_INT_EN 0x0004
@@ -181,6 +183,7 @@ struct hdmi_phy_config {u32 config[4 ]; }; +struct sti_tvout_connector *sti_hdmi_create (struct sti_tvout *tvout);void sti_hdmi_attach_ddc_client (struct i2c_client *ddc);int sti_hdmi_tx3g0c55phy_start (struct sti_hdmi *hdmi);
drivers/gpu/drm/sti/sti_tvout.c new file +682 -0
682 lines not on this page · raw message
drivers/gpu/drm/sti/sti_tvout.h new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 8/19 drm: sti: add sti layer interface definition
In reply to Benjamin GaignardSTI hardware have various input sub-devices before mixing block. Each type of sub-device have different capabilities for scaling, filtering or accepted pixel format.
This layer interface abstract those differences and make the interaction with compositor more simple.
--- drivers/gpu/drm/sti/sti_layer.h | 104 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_layer.h
drivers/gpu/drm/sti/sti_layer.h new file +104 -0
@@ -0,0 +1,104 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_LAYER_H_ +#define _STI_LAYER_H_ + +#include <drm/drmP.h> + +#define to_sti_layer (x) container_of(x, struct sti_layer, plane) + +#define STI_LAYER_TYPE_SHIFT 8 +#define STI_LAYER_TYPE_MASK (~((1<<STI_LAYER_TYPE_SHIFT)-1)) + + +enum sti_layer_type { +STI_GDP =1 <<STI_LAYER_TYPE_SHIFT , +STI_VID =2 <<STI_LAYER_TYPE_SHIFT , +STI_CUR =3 <<STI_LAYER_TYPE_SHIFT , +STI_BCK =4 <<STI_LAYER_TYPE_SHIFT +}; + +enum sti_layer_id_of_type { +STI_ID_0 =0 , +STI_ID_1 =1 , +STI_ID_2 =2 , +STI_ID_3 =3 +}; + +enum sti_layer_desc { +STI_GDP_0 =STI_GDP |STI_ID_0 , +STI_GDP_1 =STI_GDP |STI_ID_1 , +STI_GDP_2 =STI_GDP |STI_ID_2 , +STI_GDP_3 =STI_GDP |STI_ID_3 , +STI_VID_0 =STI_VID |STI_ID_0 , +STI_VID_1 =STI_VID |STI_ID_1 , +STI_CURSOR =STI_CUR , +STI_BACK =STI_BCK +}; + +struct sti_fps_info { +bool output; +int curr_frame_counter; +int last_frame_counter; +struct timespec last_timestamp; +}; + +/* +* STI layer structure +* +* @plane: drm plane it is bound to (if any) +* @fb: drm fb it is bound to +* @mode: display mode +* @desc: layer type & id +* @zorder: layer z-order +* @enabled: to know if the layer is active or not +* @src_x src_y: coordinates of the input (fb) area +* @src_w src_h: size of the input (fb) area +* @dst_x dst_y: coordinates of the output (crtc) area +* @dst_w dst_h: size of the output (crtc) area +* @format: format +* @pitches: pitch of 'planes' (eg: Y, U, V) +* @offsets: offset of 'planes' +* @paddr: physical address of the input buffer +* @fps_info: frame per second info +*/ +struct sti_layer { +struct drm_plane plane; +struct drm_framebuffer *fb; +struct drm_display_mode *mode; +enum sti_layer_desc desc; +int zorder; +bool enabled; +int src_x, src_y; +int src_w, src_h; +int dst_x, dst_y; +int dst_w, dst_h; +uint32_t format; +int pitches[4 ]; +int offsets[4 ]; +dma_addr_t paddr; +struct sti_fps_info fps_info; +}; + +struct sti_layer *sti_layer_create (struct device *dev,int desc, +void __iomem *baseaddr); +int sti_layer_prepare (struct sti_layer *layer,struct drm_framebuffer *fb, +struct drm_display_mode *mode, +int dest_x,int dest_y, +int dest_w,int dest_h, +int src_x,int src_y, +int src_w,int src_h); +int sti_layer_commit (struct sti_layer *layer); +int sti_layer_disable (struct sti_layer *layer); +const uint32_t *sti_layer_get_formats (struct sti_layer *layer); +int sti_layer_get_nb_formats (struct sti_layer *layer); +struct sti_layer *sti_layer_find_layer (struct sti_layer *layer[], +enum sti_layer_desc desc); +const char *sti_layer_to_str (struct sti_layer *layer); +#endif
Signature · 1 line
1.9.0
PATCH 9/19 drm: sti: add GDP layer
In reply to Benjamin GaignardGeneric Display Pipeline are one of the compositor input sub-devices. GDP are dedicated to graphic input like RGB plans.
--- drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_gdp.c | 491 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 73 ++++++ drivers/gpu/drm/sti/sti_layer.h | 5 + drivers/gpu/drm/sti/sti_vtg.c | 14 +- drivers/gpu/drm/sti/sti_vtg_utils.h | 3 +- 6 files changed, 583 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h
drivers/gpu/drm/sti/Makefile +1 -0
@@ -1,6 +1,7 @@ ccflags-y := -Iinclude/drm stidrm-y := \ + sti_gdp.o \ sti_tvout.o \ sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \
drivers/gpu/drm/sti/sti_gdp.c new file +491 -0
491 lines not on this page · raw message
drivers/gpu/drm/sti/sti_gdp.h new file +73 -0
73 lines not on this page · raw message
drivers/gpu/drm/sti/sti_layer.h +5 -0
@@ -10,6 +10,7 @@#define _STI_LAYER_H_#include <drm/drmP.h> +#include "sti_gdp.h" #define to_sti_layer (x) container_of(x, struct sti_layer, plane)
@@ -67,6 +68,7 @@ struct sti_fps_info {* @offsets: offset of 'planes' * @paddr: physical address of the input buffer * @fps_info: frame per second info +* @gdp: related GDP (if the layer is a GDP) */ struct sti_layer {struct drm_plane plane;
@@ -74,6 +76,7 @@ struct sti_layer {struct drm_display_mode *mode;enum sti_layer_desc desc;int zorder; +int mixer_id;bool enabled;int src_x, src_y;int src_w, src_h;
@@ -84,12 +87,14 @@ struct sti_layer {int offsets[4 ];dma_addr_t paddr;struct sti_fps_info fps_info; +struct sti_gdp *gdp; };struct sti_layer *sti_layer_create (struct device *dev,int desc,void __iomem *baseaddr); int sti_layer_prepare(struct sti_layer *layer, struct drm_framebuffer *fb, struct drm_display_mode *mode, + int mixer_id, int dest_x, int dest_y, int dest_w, int dest_h, int src_x, int src_y,
drivers/gpu/drm/sti/sti_vtg.c +11 -3
@@ -51,7 +51,10 @@#define VTG_BOT_V_HD_3 0x0110/* IRQ mask */ -#define VTG_IRQ_MASK ((1L<<1) | (1L<<0)) +#define VTG_IRQ_TOP_FIELD_MASK (1L << 1) +#define VTG_IRQ_BOTTOM_FIELD_MASK (1L << 0) +#define VTG_IRQ_MASK (VTG_IRQ_TOP_FIELD_MASK | \ + VTG_IRQ_BOTTOM_FIELD_MASK)/* Delay introduced by the AWG in nb of pixels */ #define AWG_DELAY_HD (-9)
@@ -315,8 +318,13 @@ static irqreturn_t vtg_irq_thread(int irq, void *arg)/* sync bus write */ readl (regs +VTG_HOST_ITS ); -raw_notifier_call_chain (&vtg->notifier_list, -VTG_VBLANK_EVENT , &vtg->type); +if (status &VTG_IRQ_TOP_FIELD_MASK ) { +raw_notifier_call_chain (&vtg->notifier_list, +VTG_TOP_FIELD_EVENT , &vtg->type); + }else { +raw_notifier_call_chain (&vtg->notifier_list, +VTG_BOTTOM_FIELD_EVENT , &vtg->type); + }return IRQ_HANDLED ; }
drivers/gpu/drm/sti/sti_vtg_utils.h +2 -1
@@ -14,7 +14,8 @@#define VTG_MAIN 0#define VTG_AUX 1 -#define VTG_VBLANK_EVENT 1 +#define VTG_TOP_FIELD_EVENT 1 +#define VTG_BOTTOM_FIELD_EVENT 2int sti_vtg_setconfig (int main_aux,const struct drm_display_mode *mode);int sti_vtg_register_client (int main_aux,struct notifier_block *nb);
Signature · 1 line
1.9.0
PATCH 10/19 drm: sti: add VID layer
In reply to Benjamin GaignardVIDeo plug are one of the compositor input sub-devices. VID are dedicated to video inputs like YUV plans.
--- drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_layer.h | 4 ++ drivers/gpu/drm/sti/sti_vid.c | 138 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_vid.h | 33 ++++++++++ 4 files changed, 176 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h
drivers/gpu/drm/sti/Makefile +1 -0
@@ -2,6 +2,7 @@ ccflags-y := -Iinclude/drm stidrm-y := \ sti_gdp.o \ + sti_vid.o \ sti_tvout.o \ sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \
drivers/gpu/drm/sti/sti_layer.h +4 -0
@@ -11,6 +11,7 @@#include <drm/drmP.h> #include "sti_gdp.h" +#include "sti_vid.h" #define to_sti_layer (x) container_of(x, struct sti_layer, plane)
@@ -58,6 +59,7 @@ struct sti_fps_info {* @mode: display mode * @desc: layer type & id * @zorder: layer z-order +* @mixer_id: id of the mixer used to display the layer * @enabled: to know if the layer is active or not * @src_x src_y: coordinates of the input (fb) area * @src_w src_h: size of the input (fb) area
@@ -69,6 +71,7 @@ struct sti_fps_info {* @paddr: physical address of the input buffer * @fps_info: frame per second info * @gdp: related GDP (if the layer is a GDP) +* @vid: related VID (if the layer is a VID/VDP) */ struct sti_layer {struct drm_plane plane;
@@ -88,6 +91,7 @@ struct sti_layer {dma_addr_t paddr;struct sti_fps_info fps_info;struct sti_gdp *gdp; +struct sti_vid *vid; }; struct sti_layer *sti_layer_create(struct device *dev, int desc,
drivers/gpu/drm/sti/sti_vid.c new file +138 -0
138 lines not on this page · raw message
drivers/gpu/drm/sti/sti_vid.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Fabien Dessenne <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_VID_H_ +#define _STI_VID_H_ + +/* +* STI VID structure +* +* @device: driver device +* @regs: subdevice register +* @get_formats: get VID supported formats +* @get_nb_formats: get number of format supported +* @prepare: prepare VID before rendering +* @commit: set VID for rendering +* @disable: disable VID +*/ +struct sti_vid { +struct device *dev; +void __iomem *regs; +const uint32_t * (*get_formats)(void ); +int (*get_nb_formats)(void ); +int (*prepare)(void *layer,bool first_prepare); +int (*commit)(void *layer); +int (*disable)(void *layer); +}; + +struct sti_vid *sti_vid_create (struct device *dev,void __iomem *baseaddr); + +#endif
Signature · 1 line
1.9.0
PATCH 11/19 drm: sti: add Mixer
In reply to Benjamin GaignardMixer hardware IP is responsible of mixing the different inputs layers. Z-order is managed by the mixer.
We could 2 mixers: one for main path and one for auxilary path
--- drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_mixer.c | 241 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_mixer.h | 52 +++++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h
drivers/gpu/drm/sti/Makefile +1 -0
@@ -1,6 +1,7 @@ ccflags-y := -Iinclude/drm stidrm-y := \ + sti_mixer.o \ sti_gdp.o \ sti_vid.o \ sti_tvout.o \
drivers/gpu/drm/sti/sti_mixer.c new file +241 -0
241 lines not on this page · raw message
drivers/gpu/drm/sti/sti_mixer.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 12/19 drm: sti: add Compositor
In reply to Benjamin GaignardCompositor control all the input sub-devices and the mixer. It is the main entry point for composition.
Layer interface is used to control the layer.
--- drivers/gpu/drm/sti/Kconfig | 1 + drivers/gpu/drm/sti/Makefile | 2 + drivers/gpu/drm/sti/sti_compositor.c | 187 +++++++++++++++++++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++++++++++ drivers/gpu/drm/sti/sti_layer.c | 309 +++++++++++++++++++++++++++++++++++ 5 files changed, 583 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c
drivers/gpu/drm/sti/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_STI tristate "DRM Support for STMicroelectronics SoC stiH41x Series" depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) + select DRM_KMS_CMA_HELPER help Choose this option to enable DRM on STM stiH41x chipset
drivers/gpu/drm/sti/Makefile +2 -0
@@ -1,7 +1,9 @@ ccflags-y := -Iinclude/drm stidrm-y := \ + sti_compositor.o \ sti_mixer.o \ + sti_layer.o \ sti_gdp.o \ sti_vid.o \ sti_tvout.o \
drivers/gpu/drm/sti/sti_compositor.c new file +187 -0
187 lines not on this page · raw message
drivers/gpu/drm/sti/sti_compositor.h new file +84 -0
84 lines not on this page · raw message
drivers/gpu/drm/sti/sti_layer.c new file +309 -0
309 lines not on this page · raw message
Signature · 1 line
1.9.0
PATCH 13/19 drm: sti: add debug to GDP
In reply to Benjamin GaignardAllow to get more detailed debug information on GDP
--- drivers/gpu/drm/sti/sti_drm_drv.h | 44 +++++++ drivers/gpu/drm/sti/sti_gdp.c | 235 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 2 + 3 files changed, 281 insertions(+) create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h
drivers/gpu/drm/sti/sti_drm_drv.h new file +44 -0
@@ -0,0 +1,44 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_DRV_H_ +#define _STI_DRM_DRV_H_ + +#include <linux/platform_device.h> + +#include <drm/drmP.h> + +#include "sti_compositor.h" +#include "sti_tvout.h" + +extern struct platform_driver sti_compositor_driver; +extern struct platform_driver sti_vtac_tx_driver; +extern struct platform_driver sti_vtac_rx_driver; +extern struct platform_driver sti_vtg_driver; +extern struct platform_driver sti_tvout_driver; +extern struct platform_driver sti_hdmi_driver; +extern struct platform_driver sti_hda_driver; + +/* +* STI drm private structure +* This structure is stored as private in the drm_device +* +* @compo: compositor +* @tvout: TV OUT +* @pageflip_evt_list: list of pending page flip requests +* @plane_zorder_property: z-order property for CRTC planes +*/ +struct sti_drm_private { +struct sti_compositor *compo; +struct sti_tvout *tvout; +struct list_head pageflip_evt_list; +struct drm_property *plane_zorder_property; +}; + +#define STI_MAX_FB_HEIGHT 4096 +#define STI_MAX_FB_WIDTH 4096 + +#endif
drivers/gpu/drm/sti/sti_gdp.c +235 -0
289 lines not on this page · raw message
drivers/gpu/drm/sti/sti_gdp.h +2 -0
@@ -69,5 +69,7 @@ struct sti_gdp {struct sti_gdp *sti_gdp_create (struct device *dev,int id,void __iomem *baseaddr); +int sti_gdp_dbg_show (struct seq_file *m,void *arg); +int sti_gdp_node_dbg_show (struct seq_file *m,void *arg);#endif
Signature · 1 line
1.9.0
PATCH 14/19 drm: sti: add debug to VID
In reply to Benjamin GaignardMake VIdeo plug more verbose on what is on going
--- drivers/gpu/drm/sti/sti_vid.c | 121 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_vid.h | 1 + 2 files changed, 122 insertions(+)
drivers/gpu/drm/sti/sti_vid.c +121 -0
@@ -8,6 +8,8 @@#include "sti_vid.h" #include "sti_layer.h" +#include "sti_compositor.h" +#include "sti_drm_drv.h" #include "sti_vtg_utils.h" /* Registers */
@@ -49,6 +51,8 @@ static int sti_vid_prepare_layer(void *lay, bool first_prepare)struct sti_layer *layer = (struct sti_layer *)lay;struct sti_vid *vid = layer->vid; +dev_dbg (vid->dev,"%s %s\n" , __func__,sti_layer_to_str (layer)); +/* Unmask */ val =readl (vid->regs +VID_CTL ); val &= ~VID_CTL_IGNORE ;
@@ -64,6 +68,8 @@ static int sti_vid_commit_layer(void *lay)struct drm_display_mode *mode = layer->mode;u32 ydo, xdo, yds, xds; +dev_dbg (vid->dev,"%s %s\n" , __func__,sti_layer_to_str (layer)); + ydo =sti_vtg_get_line_number (*mode, layer->dst_y); yds =sti_vtg_get_line_number (*mode, layer->dst_y + layer->dst_h -1 ); xdo =sti_vtg_get_pixel_number (*mode, layer->dst_x);
@@ -81,6 +87,8 @@ static int sti_vid_disable_layer(void *lay)struct sti_layer *layer = (struct sti_layer *)lay;struct sti_vid *vid = layer->vid; +DRM_DEBUG_DRIVER ("%s\n" ,sti_layer_to_str (layer)); +/* Mask */ val =readl (vid->regs +VID_CTL ); val |=VID_CTL_IGNORE ;
@@ -136,3 +144,116 @@ struct sti_vid *sti_vid_create(struct device *dev, void __iomem *baseaddr)return vid; } + +static void sti_vid_dbg_ctl (struct seq_file *m,int val) +{ + val = val >>30 ; +seq_puts (m,"\t" ); + +if (!(val &1 )) +seq_puts (m,"NOT " ); +seq_puts (m,"ignored on main mixer - " ); + +if (!(val &2 )) +seq_puts (m,"NOT " ); +seq_puts (m,"ignored on aux mixer" ); +} + +static void sti_vid_dbg_vpo (struct seq_file *m,int val) +{ +seq_printf (m,"\txdo:%4d\tydo:%4d" , val &0x0FFF , (val >>16 ) &0x0FFF ); +} + +static void sti_vid_dbg_vps (struct seq_file *m,int val) +{ +seq_printf (m,"\txds:%4d\tyds:%4d" , val &0x0FFF , (val >>16 ) &0x0FFF ); +} + +static void sti_vid_dbg_mst (struct seq_file *m,int val) +{ +if (val &1 ) +seq_puts (m,"\tBUFFER UNDERFLOW!" ); +} + +#define DBG_DUMP (reg) \ + seq_printf(m, "\n " #reg "\t 0x%08X", readl(vid->regs + reg)) + +int sti_vid_dbg_show (struct seq_file *m,void *arg) +{ +struct drm_info_node *node = (struct drm_info_node *)m->private; +struct drm_device *dev = node->minor->dev; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +enum sti_layer_desc vid_id = *(enum sti_layer_desc *)arg; +struct sti_layer *layer; +struct sti_vid *vid; +struct drm_plane *plane; +struct drm_crtc *crtc; +struct drm_framebuffer *fb; + +if (compo ==NULL ) { +seq_puts (m,"No compo available\n" ); + goto out; + } + + layer =sti_layer_find_layer (compo->layer, vid_id); +if (!layer) { +seq_puts (m,"Cannot find video layer\n" ); + goto out; + } + vid = layer->vid; + +seq_printf (m,"\n%s (associated with the mixer_id %d)" , +sti_layer_to_str (layer), layer->mixer_id); +seq_printf (m,"\t %d frame updates" , + layer->fps_info.curr_frame_counter); + +DBG_DUMP (VID_CTL ); +sti_vid_dbg_ctl (m,readl (vid->regs +VID_CTL )); +DBG_DUMP (VID_ALP ); +DBG_DUMP (VID_CLF ); +DBG_DUMP (VID_VPO ); +sti_vid_dbg_vpo (m,readl (vid->regs +VID_VPO )); +DBG_DUMP (VID_VPS ); +sti_vid_dbg_vps (m,readl (vid->regs +VID_VPS )); +DBG_DUMP (VID_KEY1 ); +DBG_DUMP (VID_KEY2 ); +DBG_DUMP (VID_MPR0 ); +DBG_DUMP (VID_MPR1 ); +DBG_DUMP (VID_MPR2 ); +DBG_DUMP (VID_MPR3 ); +DBG_DUMP (VID_MST ); +sti_vid_dbg_mst (m,readl (vid->regs +VID_MST )); +DBG_DUMP (VID_BC ); +DBG_DUMP (VID_TINT ); +DBG_DUMP (VID_CSAT ); + +seq_puts (m,"\n" ); + + plane = &layer->plane; +if (!plane->base.id) { +seq_puts (m," Not connected to any DRM PLANE\n" ); + goto out; + } +seq_printf (m," Connected to DRM PLANE #%d which is:\n" , + plane->base.id); + + crtc = plane->crtc; +if (!crtc) { +seq_puts (m,"\tNot connected to any DRM CRTC\n" ); + goto out; + } +seq_printf (m,"\tConnected to DRM CRTC #%d\n" , crtc->base.id); + + fb = crtc->fb; +if (!fb) { +seq_puts (m,"\tNot connected to any DRM FB\n" ); + goto out; + } +seq_printf (m,"\tConnected to DRM FB #%d, %dx%d, %.4s\n" , + fb->base.id, + fb->width, fb->height, (char *)&fb->pixel_format); + +out: +return 0 ; +}
drivers/gpu/drm/sti/sti_vid.h +1 -0
@@ -29,5 +29,6 @@ struct sti_vid { };struct sti_vid *sti_vid_create (struct device *dev,void __iomem *baseaddr); +int sti_vid_dbg_show (struct seq_file *m,void *arg);#endif
Signature · 1 line
1.9.0
PATCH 15/19 drm: sti: add debug to TVout
In reply to Benjamin GaignardUse debugfs to dump information about TVout
--- drivers/gpu/drm/sti/sti_tvout.c | 181 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+)
drivers/gpu/drm/sti/sti_tvout.c +181 -0
@@ -17,6 +17,7 @@#include "sti_tvout.h" #include "sti_hdmi.h" #include "sti_hda.h" +#include "sti_drm_drv.h" /* glue regsiters */ #define TVO_CSC_MAIN_M0 0x000
@@ -604,6 +605,186 @@ void sti_tvout_disable(struct sti_tvout *tvout, connector->stop (connector); } +/* +* Debugfs +*/ +#define TVOUT_DBG_DUMP (reg) seq_printf(m, "\n %-25s 0x%08X", #reg, \ + readl(tvout->regs + reg)) +#define TVOUT_CONNECTOR_NAME_MAX_LENGHT 10 +#define MAX_STRING_LENGTH 55 + +static int sti_tvout_dbg_type_to_connector_name (enum sti_tvout_connector_type + type,char *name) +{ +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : +snprintf (name,TVOUT_CONNECTOR_NAME_MAX_LENGHT ,"HDMI" ); +break ; +case STI_TVOUT_CONNECTOR_HDA : +snprintf (name,TVOUT_CONNECTOR_NAME_MAX_LENGHT ,"HD Analog" ); +break ; +default : +return -1 ; + } + +return 0 ; +} + +static void tvout_dbg_vip (struct seq_file *m,int val) +{ +int r, g, b, tmp, mask; +char str[MAX_STRING_LENGTH ]; +static const char *const reorder[] = {"Y_G" ,"Cb_B" ,"Cr_R" }; +static const char *const clipping[] = {"No" ,"EAV/SAV" , +"Limited range RGB/Y" ,"Limited range Cb/Cr" , +"decided by register" }; +static const char *const round[] = {"8-bit" ,"10-bit" ,"12-bit" }; +static const char *const input_sel[] = {"Main (color matrix enabled)" , +"Main (color matrix by-passed)" ,"" ,"" ,"" ,"" ,"" ,"" , +"Aux (color matrix enabled)" ,"Aux (color matrix by-passed)" , +"" ,"" ,"" ,"" ,"" ,"Force value" + }; + +seq_puts (m,"\t" ); + + mask =TVO_VIP_REORDER_MASK <<TVO_VIP_REORDER_R_SHIFT ; + r = (val & mask) >>TVO_VIP_REORDER_R_SHIFT ; + mask =TVO_VIP_REORDER_MASK <<TVO_VIP_REORDER_G_SHIFT ; + g = (val & mask) >>TVO_VIP_REORDER_G_SHIFT ; + mask =TVO_VIP_REORDER_MASK <<TVO_VIP_REORDER_B_SHIFT ; + b = (val & mask) >>TVO_VIP_REORDER_B_SHIFT ; +snprintf (str,MAX_STRING_LENGTH ,"Reorder: %s->%s %s->%s %s->%s" , + reorder[r], reorder[TVO_VIP_REORDER_CR_R_SEL ], + reorder[g], reorder[TVO_VIP_REORDER_Y_G_SEL ], + reorder[b], reorder[TVO_VIP_REORDER_CB_B_SEL ]); +seq_printf (m,"%-55s" , str); + + mask =TVO_VIP_CLIP_MASK <<TVO_VIP_CLIP_SHIFT ; + tmp = (val & mask) >>TVO_VIP_CLIP_SHIFT ; +snprintf (str,MAX_STRING_LENGTH ,"Clipping: %s" , clipping[tmp]); +seq_printf (m,"%-55s" , str); + +seq_printf (m,"\n%-40s" ,"" ); + + mask =TVO_VIP_RND_MASK <<TVO_VIP_RND_SHIFT ; + tmp = (val & mask) >>TVO_VIP_RND_SHIFT ; +snprintf (str,MAX_STRING_LENGTH , +"Round: input data rounded to %s per component" , round[tmp]); +seq_printf (m,"%-55s" , str); + + tmp = (val &TVO_VIP_SEL_INPUT_MASK ); +snprintf (str,MAX_STRING_LENGTH ,"Input selection: %s" , input_sel[tmp]); +seq_printf (m,"%-55s" , str); +} + +static void tvout_dbg_hd_dac_cfg (struct seq_file *m,int val) +{ +seq_puts (m,"\t HD DAC " ); +seq_puts (m, val &1 ?"disabled" :"enabled" ); +} + +static int tvout_dbg_show (struct seq_file *m, +enum sti_tvout_connector_type type) +{ +struct drm_info_node *node = (struct drm_info_node *)m->private; +struct drm_device *dev = node->minor->dev; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_tvout *tvout = dev_priv->tvout; +struct sti_tvout_connector *connector = tvout->connector[type]; +char name[TVOUT_CONNECTOR_NAME_MAX_LENGHT ]; +int ret; + +if (!connector) +return -1 ; + +if (!connector->is_enabled) +return -1 ; + + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret; + +if (tvout ==NULL ) { +seq_puts (m,"No tvout available" ); + goto out; + } + + ret =sti_tvout_dbg_type_to_connector_name (type, name); +if (ret) { +seq_puts (m,"No connector!" ); + goto out; + } + +seq_printf (m,"\n%s connector: " , name); +seq_printf (m,"\nTVOUT: (virt base addr = 0x%p)" , tvout->regs); +if (connector->is_enabled (connector)) { +if (connector->main_path) { +seq_puts (m,"\n Connected to the main path" ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M0 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M1 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M2 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M3 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M4 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M5 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M6 ); +TVOUT_DBG_DUMP (TVO_CSC_MAIN_M7 ); +TVOUT_DBG_DUMP (TVO_MAIN_IN_VID_FORMAT ); + }else { +seq_puts (m,"\n Connected to the auxiliary path" ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M0 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M2 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M3 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M4 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M5 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M6 ); +TVOUT_DBG_DUMP (TVO_CSC_AUX_M7 ); +TVOUT_DBG_DUMP (TVO_AUX_IN_VID_FORMAT ); + } + }else +seq_puts (m," Disabled" ); + +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : +TVOUT_DBG_DUMP (TVO_VIP_HDMI ); +tvout_dbg_vip (m,readl (tvout->regs +TVO_VIP_HDMI )); +TVOUT_DBG_DUMP (TVO_HDMI_FORCE_COLOR_0 ); +TVOUT_DBG_DUMP (TVO_HDMI_FORCE_COLOR_1 ); +TVOUT_DBG_DUMP (TVO_HDMI_CLIP_VALUE_B_CB ); +TVOUT_DBG_DUMP (TVO_HDMI_CLIP_VALUE_Y_G ); +TVOUT_DBG_DUMP (TVO_HDMI_CLIP_VALUE_R_CR ); +TVOUT_DBG_DUMP (TVO_HDMI_SYNC_SEL ); +TVOUT_DBG_DUMP (TVO_HDMI_DFV_OBS ); +break ; +case STI_TVOUT_CONNECTOR_HDA : +TVOUT_DBG_DUMP (TVO_VIP_HDF ); +tvout_dbg_vip (m,readl (tvout->regs +TVO_VIP_HDF )); +TVOUT_DBG_DUMP (TVO_HD_SYNC_SEL ); +TVOUT_DBG_DUMP (TVO_HD_DAC_CFG_OFF ); +tvout_dbg_hd_dac_cfg (m, +readl (tvout->regs +TVO_HD_DAC_CFG_OFF )); +break ; +default : + goto out; + } + +if (connector->dbg_show) + connector->dbg_show (connector, m); +out: +seq_puts (m,"\n\n" ); +mutex_unlock (&dev->struct_mutex); +return 0 ; +} + +int sti_tvout_hdmi_dbg_show (struct seq_file *m,void *arg) +{ +return tvout_dbg_show (m,STI_TVOUT_CONNECTOR_HDMI ); +} + +int sti_tvout_hda_dbg_show (struct seq_file *m,void *arg) +{ +return tvout_dbg_show (m,STI_TVOUT_CONNECTOR_HDA ); +} +static int sti_tvout_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
Signature · 1 line
1.9.0
PATCH 16/19 drm: sti: add debug to mixer
In reply to Benjamin GaignardMake mixer driver more verbose
--- drivers/gpu/drm/sti/sti_mixer.c | 164 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_mixer.h | 2 + 2 files changed, 166 insertions(+)
drivers/gpu/drm/sti/sti_mixer.c +164 -0
@@ -6,7 +6,9 @@* License terms: GNU General Public License (GPL), version 2 */ +#include "sti_drm_drv.h" #include "sti_mixer.h" +#include "sti_compositor.h" #include "sti_vtg_utils.h" /* Identity: G=Y , B=Cb , R=Cr */
@@ -139,6 +141,8 @@ int sti_mixer_set_layer_depth(struct sti_mixer *mixer, struct sti_layer *layer) mask =GAM_DEPTH_MASK_ID << (3 * depth); layer_id = layer_id << (3 * depth); +DRM_DEBUG_DRIVER ("%s %s depth=%d\n" ,sti_mixer_to_str (mixer), +sti_layer_to_str (layer), depth);dev_dbg (mixer->dev,"GAM_MIXER_MAIN_CRB val 0x%x mask 0x%x\n" , layer_id, mask);sti_mixer_reg_writemask (mixer,GAM_MIXER_MAIN_CRB , layer_id, mask);
@@ -197,6 +201,9 @@ int sti_mixer_set_layer_status(struct sti_mixer *mixer, {u32 mask, val; +DRM_DEBUG_DRIVER ("%s %s %s\n" , status ?"enable" :"disable" , +sti_mixer_to_str (mixer),sti_layer_to_str (layer)); + mask =sti_mixer_get_layer_mask (layer);if (!mask) {DRM_ERROR ("Can not find layer mask\n" );
@@ -239,3 +246,160 @@ struct sti_mixer *sti_mixer_create(struct device *dev, int id,return mixer; } + +static void sti_mixer_dbg_ctl (struct seq_file *m,int val) +{ +int count =0 ; + +seq_puts (m,"\tEnabled: " ); +if (val &1 ) { +seq_puts (m,"BKG " ); + count++; + } + val = val >>1 ; + +if (val &1 ) { +seq_puts (m,"VID0 " ); + count++; + } + val = val >>1 ; +if (val &1 ) { +seq_puts (m,"VID1 " ); + count++; + } + val = val >>1 ; +if (val &1 ) { +seq_puts (m,"GDP0 " ); + count++; + } + val = val >>1 ; +if (val &1 ) { +seq_puts (m,"GDP1 " ); + count++; + } + val = val >>1 ; +if (val &1 ) { +seq_puts (m,"GDP2 " ); + count++; + } + val = val >>1 ; +if (val &1 ) { +seq_puts (m,"GDP3 " ); + count++; + } +if (!count) +seq_puts (m,"Nothing" ); +} + +static void sti_mixer_dbg_crb (struct seq_file *m,int val) +{ +int i; + +seq_puts (m,"\tDepth: " ); +for (i =0 ; i <GAM_MIXER_NB_DEPTH_LEVEL ; i++) { +switch (val &GAM_DEPTH_MASK_ID ) { +case GAM_DEPTH_VID0_ID : +seq_puts (m,"VID0" ); +break ; +case GAM_DEPTH_VID1_ID : +seq_puts (m,"VID1" ); +break ; +case GAM_DEPTH_GDP0_ID : +seq_puts (m,"GDP0" ); +break ; +case GAM_DEPTH_GDP1_ID : +seq_puts (m,"GDP1" ); +break ; +case GAM_DEPTH_GDP2_ID : +seq_puts (m,"GDP2" ); +break ; +case GAM_DEPTH_GDP3_ID : +seq_puts (m,"GDP3" ); +break ; +default : +seq_puts (m,"---" ); + } +if (i <GAM_MIXER_NB_DEPTH_LEVEL -1 ) +seq_puts (m," < " ); + val = val >>3 ; + } +} + +static void sti_mixer_dbg_mxn (struct seq_file *m,void *addr) +{ +int i; + +for (i =1 ; i <8 ; i++) +seq_printf (m,"-0x%08X" , (int )readl (addr + i *4 )); +} + +#define MIXER_DBG_DUMP (reg) seq_printf(m, "\n " #reg "\t 0x%08X", \ + sti_mixer_reg_read(mixer, reg)) + +int sti_mixer_dbg_show (struct seq_file *m,void *arg) +{ +struct drm_info_node *node = (struct drm_info_node *)m->private; +struct drm_device *dev = node->minor->dev; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +int i, ret; + + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret; + +if (compo ==NULL ) { +seq_puts (m,"No compositor available\n" ); + goto out; + } + +for (i =0 ; i < compo->nb_mixers; i++) { +struct drm_crtc *crtc; +struct drm_framebuffer *fb; +struct sti_mixer *mixer = compo->mixer[i]; + +seq_printf (m,"\n%s" ,sti_mixer_to_str (mixer)); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_CTL ); +sti_mixer_dbg_ctl (m, +sti_mixer_reg_read (mixer, +GAM_MIXER_MAIN_CTL )); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_BKC ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_BCO ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_BCS ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_AVO ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_AVS ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_CRB ); +sti_mixer_dbg_crb (m, +sti_mixer_reg_read (mixer, +GAM_MIXER_MAIN_CRB )); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_ACT ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_MBP ); +MIXER_DBG_DUMP (GAM_MIXER_MAIN_MX0 ); +sti_mixer_dbg_mxn (m, mixer->regs +GAM_MIXER_MAIN_MX0 ); +seq_puts (m,"\n" ); + + crtc = &mixer->drm_crtc; +if (!crtc) { +seq_puts (m," Not connected to any DRM CRTC\n" ); +continue ; + } +seq_printf (m," Connected to DRM CRTC #%d which is:\n" , + crtc->base.id); +seq_puts (m, crtc->enabled ?"\tEnabled\n" :"\tDisabled\n" ); +seq_printf (m,"\tMode: %s %dHz\n" , + crtc->mode.name, crtc->mode.vrefresh); +seq_printf (m,"\tat %d,%d\n" , crtc->x, crtc->y); + + fb = crtc->fb; +if (!fb) { +seq_puts (m,"\tNot connected to any DRM FB\n" ); +continue ; + } +seq_printf (m,"\tConnected to DRM FB #%d, %dx%d, %.4s\n" , + fb->base.id, + fb->width, fb->height, (char *)&fb->pixel_format); + } +out: +mutex_unlock (&dev->struct_mutex); +return 0 ; +}
drivers/gpu/drm/sti/sti_mixer.h +2 -0
@@ -43,6 +43,8 @@ int sti_mixer_active_video_area(struct sti_mixer *mixer,void sti_mixer_set_background_status (struct sti_mixer *mixer,bool enable); +int sti_mixer_dbg_show (struct seq_file *m,void *arg); +/* depth in Cross-bar control = z order */ #define GAM_MIXER_NB_DEPTH_LEVEL 7
Signature · 1 line
1.9.0
PATCH 17/19 drm: sti: Add DRM driver itself
In reply to Benjamin GaignardMake the link between all the hardware drivers and DRM/KMS interface. Create the driver itself and make it register all the sub-components. Use GEM CMA helpers for buffer allocation.
--- drivers/gpu/drm/sti/Kconfig | 8 + drivers/gpu/drm/sti/Makefile | 28 +- drivers/gpu/drm/sti/sti_compositor.c | 2 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 ++ drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 ++ drivers/gpu/drm/sti/sti_drm_drv.c | 466 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 ++ drivers/gpu/drm/sti/sti_drm_plane.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 2 + 13 files changed, 1594 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h
drivers/gpu/drm/sti/Kconfig +8 -0
@@ -1,10 +1,18 @@ config DRM_STI tristate "DRM Support for STMicroelectronics SoC stiH41x Series" depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) + select DRM_KMS_HELPER + select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER help Choose this option to enable DRM on STM stiH41x chipset +config DRM_STI_FBDEV + tristate "DRM frame buffer device for STMicroelectronics SoC stiH41x Serie" + depends on DRM_STI + help + Choose this option to enable FBDEV on top of DRM for STM stiH41x chipset + config VTAC_STI tristate "Video Trafic Advance Communication Rx and Tx for STMicroelectronics SoC stiH41x Series" depends on DRM_STI
drivers/gpu/drm/sti/Makefile +16 -12
@@ -1,17 +1,21 @@ ccflags-y := -Iinclude/drm -stidrm-y := \ - sti_compositor.o \ - sti_mixer.o \ - sti_layer.o \ - sti_gdp.o \ - sti_vid.o \ - sti_tvout.o \ - sti_hdmi.o \ - sti_hdmi_tx3g0c55phy.o \ - sti_hdmi_tx3g4c28phy.o \ - sti_hda.o \ - sti_ddc.o +stidrm-y := sti_drm_drv.o \ + sti_drm_crtc.o \ + sti_drm_plane.o \ + sti_drm_connector.o \ + sti_drm_encoder.o \ + sti_compositor.o \ + sti_mixer.o \ + sti_layer.o \ + sti_gdp.o \ + sti_vid.o \ + sti_tvout.o \ + sti_hdmi.o \ + sti_hdmi_tx3g0c55phy.o \ + sti_hdmi_tx3g4c28phy.o \ + sti_hda.o \ + sti_ddc.o obj-$(CONFIG_DRM_STI) += stidrm.o obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.o
drivers/gpu/drm/sti/sti_compositor.c +2 -0
@@ -14,6 +14,7 @@#include "sti_compositor.h" #include "sti_gdp.h" +#include "sti_drm_crtc.h" static const struct of_device_id compositor_match_types[];
@@ -98,6 +99,7 @@ static int sti_compositor_probe(struct platform_device *pdev) }DRM_DEBUG_DRIVER ("Compositor %p\n" , compo); compo->dev = dev; + compo->vtg_vblank_nb.notifier_call = sti_drm_crtc_vblank_cb;/* populate data structure depending on compatibility */ BUG_ON (!of_match_node (compositor_match_types, np)->data);
drivers/gpu/drm/sti/sti_drm_connector.c new file +195 -0
195 lines not on this page · raw message
drivers/gpu/drm/sti/sti_drm_connector.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CONNECTOR_H_ +#define _STI_DRM_CONNECTOR_H_ + +#include "sti_tvout.h" + +struct drm_connector *sti_drm_connector_create (struct drm_device *dev, +struct sti_tvout *tvout,struct drm_encoder *encoder, +enum sti_tvout_connector_type type); + +#endif
drivers/gpu/drm/sti/sti_drm_crtc.c new file +440 -0
440 lines not on this page · raw message
drivers/gpu/drm/sti/sti_drm_crtc.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CRTC_H_ +#define _STI_DRM_CRTC_H_ + +#include <drm/drmP.h> + +#include "sti_mixer.h" + +int sti_drm_crtc_init (struct drm_device *drm_dev,struct sti_mixer *mixer); +int sti_drm_crtc_enable_vblank (struct drm_device *dev,int crtc); +void sti_drm_crtc_disable_vblank (struct drm_device *dev,int crtc); +int sti_drm_crtc_vblank_cb (struct notifier_block *nb, +unsigned long event,void *data); +bool sti_drm_crtc_is_main (struct drm_crtc *drm_crtc); + +#endif
drivers/gpu/drm/sti/sti_drm_drv.c new file +466 -0
466 lines not on this page · raw message
drivers/gpu/drm/sti/sti_drm_encoder.c new file +201 -0
201 lines not on this page · raw message
drivers/gpu/drm/sti/sti_drm_encoder.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_ENCODER_H_ +#define _STI_DRM_ENCODER_H_ + +#include "sti_tvout.h" + +struct drm_encoder *sti_drm_encoder_create (struct drm_device *dev, +struct sti_tvout *tvout,unsigned int possible_crtcs, +enum sti_tvout_connector_type type); + +#endif
drivers/gpu/drm/sti/sti_drm_plane.c new file +195 -0
195 lines not on this page · raw message
drivers/gpu/drm/sti/sti_drm_plane.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_PLANE_H_ +#define _STI_DRM_PLANE_H_ + +#include <drm/drmP.h> +#include "sti_layer.h" + +struct drm_plane *sti_drm_plane_init (struct drm_device *dev, +struct sti_layer *layer,unsigned int possible_crtcs); + +#endif
drivers/gpu/drm/sti/sti_vtg_utils.h +2 -0
@@ -11,6 +11,8 @@#include <drm/drmP.h> +#define WAIT_NEXT_VSYNC_MS 50/*ms*/ +#define VTG_MAIN 0#define VTG_AUX 1
Signature · 1 line
1.9.0
Re: [PATCH v1 17/19] drm: sti: Add DRM driver itself
Quoted 1,668 lines · Benjamin Gaignard
Make the link between all the hardware drivers and DRM/KMS interface. Create the driver itself and make it register all the sub-components. Use GEM CMA helpers for buffer allocation.
Signed-off-by Benjamin Gaignard <[email protected]>Signed-off-by Vincent Abriou <[email protected]>Signed-off-by Fabien Dessenne <[email protected]>--- drivers/gpu/drm/sti/Kconfig | 8 + drivers/gpu/drm/sti/Makefile | 28 +- drivers/gpu/drm/sti/sti_compositor.c | 2 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 ++ drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 ++ drivers/gpu/drm/sti/sti_drm_drv.c | 466 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 ++ drivers/gpu/drm/sti/sti_drm_plane.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 2 + 13 files changed, 1594 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.hdrivers/gpu/drm/sti/Kconfig +8
-0@@ -1,10 +1,18 @@ config DRM_STI tristate "DRM Support for STMicroelectronics SoC stiH41x Series" depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) + select DRM_KMS_HELPER + select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER help Choose this option to enable DRM on STM stiH41x chipset +config DRM_STI_FBDEV + tristate "DRM frame buffer device for STMicroelectronics SoC stiH41x Serie" + depends on DRM_STI + help + Choose this option to enable FBDEV on top of DRM for STM stiH41x chipset + config VTAC_STI tristate "Video Trafic Advance Communication Rx and Tx for STMicroelectronics SoC stiH41x Series" depends on DRM_STIdrivers/gpu/drm/sti/Makefile +16
-12@@ -1,17 +1,21 @@ ccflags-y := -Iinclude/drm -stidrm-y := \ - sti_compositor.o \ - sti_mixer.o \ - sti_layer.o \ - sti_gdp.o \ - sti_vid.o \ - sti_tvout.o \ - sti_hdmi.o \ - sti_hdmi_tx3g0c55phy.o \ - sti_hdmi_tx3g4c28phy.o \ - sti_hda.o \ - sti_ddc.o +stidrm-y := sti_drm_drv.o \ + sti_drm_crtc.o \ + sti_drm_plane.o \ + sti_drm_connector.o \ + sti_drm_encoder.o \ + sti_compositor.o \ + sti_mixer.o \ + sti_layer.o \ + sti_gdp.o \ + sti_vid.o \ + sti_tvout.o \ + sti_hdmi.o \ + sti_hdmi_tx3g0c55phy.o \ + sti_hdmi_tx3g4c28phy.o \ + sti_hda.o \ + sti_ddc.o obj-$(CONFIG_DRM_STI) += stidrm.o obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.odrivers/gpu/drm/sti/sti_compositor.c +2
-0@@ -14,6 +14,7 @@#include "sti_compositor.h" #include "sti_gdp.h" +#include "sti_drm_crtc.h" static const struct of_device_id compositor_match_types[];@@ -98,6 +99,7 @@ static int sti_compositor_probe(struct platform_device *pdev) }DRM_DEBUG_DRIVER ("Compositor %p\n" , compo); compo->dev = dev; + compo->vtg_vblank_nb.notifier_call = sti_drm_crtc_vblank_cb;/* populate data structure depending on compatibility */ BUG_ON (!of_match_node (compositor_match_types, np)->data);drivers/gpu/drm/sti/sti_drm_connector.c new file +195
-0@@ -0,0 +1,195 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_connector.h" +#include "sti_drm_drv.h" + +#define to_sti_connector (x) container_of(x, struct sti_connector, drm_connector) + +/* +* sti specific connector structure +* +* @drm_encoder: connector object +* @encoder: associated encoder +* @tvout: pointer on tvout driver +* @type: tvout connector type +*/ +struct sti_connector { +struct drm_connector drm_connector; +struct drm_encoder *encoder; +struct sti_tvout *tvout; +enum sti_tvout_connector_type type; +}; + +static int sti_drm_connector_get_modes (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +return sti_tvout_get_modes (sti_connector->tvout, sti_connector->type, + connector); +} + +static int sti_drm_connector_mode_valid (struct drm_connector *connector, +struct drm_display_mode *mode) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; +int ret =MODE_BAD ; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (!sti_tvout_check_mode + (sti_connector->tvout, sti_connector->type, mode)) + ret =MODE_OK ; + +return ret; +} + +struct drm_encoder *sti_drm_best_encoder (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +/* Best encoder is the one associated during connector creation */ +return sti_connector->encoder; +} + +static struct drm_connector_helper_funcs sti_drm_connector_helper_funcs = { + .get_modes = sti_drm_connector_get_modes, + .mode_valid = sti_drm_connector_mode_valid, + .best_encoder = sti_drm_best_encoder, +}; + +static void sti_drm_connector_dpms (struct drm_connector *connector,int mode) +{ +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_helper_connector_dpms (connector, mode); +} + +/* get detection status of display device. */ +static enum drm_connector_status +sti_drm_connector_detect (struct drm_connector *connector,bool force) +{ +enum drm_connector_status status = connector_status_disconnected; +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (sti_tvout_connector_detect (sti_connector->tvout, + sti_connector->type)) + status = connector_status_connected; + +return status; +} + +static void sti_drm_connector_destroy (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_sysfs_connector_remove (connector); +drm_connector_cleanup (connector); +kfree (sti_connector); +} + +static struct drm_connector_funcs sti_drm_connector_funcs = { + .dpms = sti_drm_connector_dpms, + .fill_modes = drm_helper_probe_single_connector_modes, + .detect = sti_drm_connector_detect, + .destroy = sti_drm_connector_destroy, +}; + +struct drm_connector *sti_drm_connector_create (struct drm_device *dev, +struct sti_tvout *tvout, +struct drm_encoder *encoder, +enum sti_tvout_connector_type + type) +{ +struct sti_connector *sti_connector; +struct drm_connector *connector; +int connector_type; +int err; + +dev_dbg (dev->dev,"%s\n" , __func__); + +/* Create the tvout connector according to the type */ + tvout->connector[type] = tvout->connector_create[type] (tvout); +if (!tvout->connector[type]) { +DRM_INFO ("%s: failed to create connector (type = %d)\n" , + __func__, type); +return NULL ; + } + + sti_connector =kzalloc (sizeof (*sti_connector),GFP_KERNEL ); +if (!sti_connector) { +DRM_ERROR ("failed to allocate connector\n" ); +return NULL ; + } + + connector = &sti_connector->drm_connector; + +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : + connector_type =DRM_MODE_CONNECTOR_HDMIA ; + connector->polled =DRM_CONNECTOR_POLL_HPD ; +break ; +case STI_TVOUT_CONNECTOR_HDA : + connector_type = DRM_MODE_CONNECTOR_Component; +break ; +case STI_TVOUT_CONNECTOR_DVO : + connector_type =DRM_MODE_CONNECTOR_LVDS ; +break ; +case STI_TVOUT_CONNECTOR_DENC : + connector_type = DRM_MODE_CONNECTOR_Composite; +break ; +default : + connector_type = DRM_MODE_CONNECTOR_Unknown; +break ; + } + +drm_connector_init (dev, connector, &sti_drm_connector_funcs, + connector_type); +drm_connector_helper_add (connector, &sti_drm_connector_helper_funcs); + + err =drm_sysfs_connector_add (connector); +if (err) + goto err_connector; + + sti_connector->tvout = tvout; + sti_connector->encoder = encoder; + sti_connector->type = type; + + err =drm_mode_connector_attach_encoder (connector, encoder); +if (err) { +DRM_ERROR ("Failed to attach a connector to a encoder\n" ); + goto err_sysfs; + } + +DRM_DEBUG_DRIVER ("Connector has been created\n" ); + +return connector; + +err_sysfs: +drm_sysfs_connector_remove (connector); +err_connector: +drm_connector_cleanup (connector); +kfree (sti_connector); +return NULL ; +}drivers/gpu/drm/sti/sti_drm_connector.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CONNECTOR_H_ +#define _STI_DRM_CONNECTOR_H_ + +#include "sti_tvout.h" + +struct drm_connector *sti_drm_connector_create (struct drm_device *dev, +struct sti_tvout *tvout,struct drm_encoder *encoder, +enum sti_tvout_connector_type type); + +#endif drivers/gpu/drm/sti/sti_drm_crtc.c new file +440
-0@@ -0,0 +1,440 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <linux/clk.h> + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_drv.h" +#include "sti_drm_crtc.h" +#include "sti_compositor.h" +#include "sti_vtg_utils.h" + +static void sti_drm_crtc_dpms (struct drm_crtc *crtc,int mode) +{ +DRM_DEBUG_KMS ("\n" ); +} + +static void sti_drm_crtc_prepare (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); + + compo->enable = true; + +/* Prepare and enable the compo IP clock */ +if (mixer->id ==STI_MIXER_MAIN ) { +if (clk_prepare_enable (compo->clk_compo_main)) +DRM_INFO ("Failed to prepare/enable compo_main clk\n" ); + }else { +if (clk_prepare_enable (compo->clk_compo_aux)) +DRM_INFO ("Failed to prepare/enable compo_aux clk\n" ); + } +} + +static void sti_drm_crtc_commit (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; + +dev_dbg (dev,"%s\n" , __func__); +if ((!mixer || !compo)) { +DRM_ERROR ("Can not find mixer or compositor)\n" ); +return ; + } + +/* Find GDP0 which is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (layer) +sti_layer_commit (layer); +else +DRM_ERROR ("Can not find CRTC dedicated plane (GDP0)\n" ); + +/* Enable layer on mixer */ +if (sti_mixer_set_layer_status (mixer, layer, true)) +DRM_ERROR ("Can not enable layer at mixer\n" ); +} + +static bool sti_drm_crtc_mode_fixup (struct drm_crtc *crtc, +const struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +/* accept the provided drm_display_mode, do not fix it up */ +dev_dbg (crtc->dev->dev,"%s\n" , __func__); +return true; +} + +static int +sti_drm_crtc_mode_set (struct drm_crtc *crtc,struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode,int x,int y, +struct drm_framebuffer *old_fb) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; +struct clk *clk; +int rate = mode->clock *1000 ; +int res; +unsigned int w, h; + +DRM_DEBUG_KMS ("CRTC:%d (%s) fb:%d mode:%d (%s)\n" , + crtc->base.id,sti_mixer_to_str (mixer), + crtc->fb->base.id, mode->base.id, mode->name); + +DRM_DEBUG_KMS ("%d %d %d %d %d %d %d %d %d %d 0x%x 0x%x\n" , + mode->vrefresh, mode->clock, + mode->hdisplay, + mode->hsync_start, mode->hsync_end, + mode->htotal, + mode->vdisplay, + mode->vsync_start, mode->vsync_end, + mode->vtotal, mode->type, mode->flags); + +/* Set rate and prepare/enable pixel clock */ +if (mixer->id ==STI_MIXER_MAIN ) + clk = compo->clk_pix_main; +else + clk = compo->clk_pix_aux; + + res =clk_set_rate (clk, rate); +if (res <0 ) { +DRM_ERROR ("Cannot set rate (%dHz) for pix clk\n" , rate); +return 1 ; + } +if (clk_prepare_enable (clk)) { +DRM_ERROR ("Failed to prepare/enable pix clk\n" ); +return 1 ; + } + +sti_vtg_setconfig (mixer->id ==STI_MIXER_MAIN ?VTG_MAIN :VTG_AUX , + &crtc->mode); + +/* GDP0 is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Can not find GDP0)\n" ); +return 1 ; + } + +/* copy the mode data adjusted by mode_fixup() into crtc->mode +* so that hardware can be set to proper mode */ +memcpy (&crtc->mode, adjusted_mode,sizeof (*adjusted_mode)); + + res =sti_mixer_set_layer_depth (mixer, layer); +if (res) { +DRM_ERROR ("Can not set layer depth\n" ); +return 1 ; + } + res =sti_mixer_active_video_area (mixer, &crtc->mode); +if (res) { +DRM_ERROR ("Can not set active video area\n" ); +return 1 ; + } + +if ((mode->hdisplay != crtc->fb->width) || + (mode->vdisplay != crtc->fb->height)) +DRM_DEBUG_KMS ("WARNING: fb and display mode sizes differ\n" ); + + w = crtc->fb->width - x; + h = crtc->fb->height - y; + +if ((w <=0 ) || (h <=0 )) { +DRM_ERROR ("Coordinates outside FB\n" ); +return -EINVAL ; + } + +return sti_layer_prepare (layer, crtc->fb, &crtc->mode, mixer->id, +0 ,0 , w, h, x, y, w, h); +} + +static int sti_drm_crtc_mode_set_base (struct drm_crtc *crtc,int x,int y, +struct drm_framebuffer *old_fb) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; +unsigned int w, h; +int ret =0 ; + +DRM_DEBUG_KMS ("CRTC:%d (%s) fb:%d (%d,%d)\n" , + crtc->base.id,sti_mixer_to_str (mixer), + crtc->fb->base.id, x, y); + +/* GDP0 is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Can not find GDP0)\n" ); + ret =-1 ; + goto out; + } + + w = crtc->fb->width - crtc->x; + h = crtc->fb->height - crtc->y; + +if ((w <=0 ) || (h <=0 )) { +DRM_ERROR ("Coordinates outside FB\n" ); + ret = -EINVAL ; + goto out; + } + + ret =sti_layer_prepare (layer, crtc->fb, &crtc->mode, mixer->id, +0 ,0 , w, h, + crtc->x, crtc->y, w, h); +if (ret) { +DRM_ERROR ("Can not prepare layer\n" ); + goto out; + } + +sti_drm_crtc_commit (crtc); +out: +return ret; +} + +static void sti_drm_crtc_load_lut (struct drm_crtc *crtc) +{ +dev_dbg (crtc->dev->dev,"%s\n" , __func__); +} + +static void sti_drm_crtc_disable (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; + +if (!compo->enable) +return ; + +DRM_DEBUG_KMS ("CRTC:%d (%s)\n" , crtc->base.id,sti_mixer_to_str (mixer)); + +/* Disable Background */ +sti_mixer_set_background_status (mixer, false); + +/* Disable GDP0 */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Cannot find GDP0\n" ); +return ; + } + +/* Disable layer at mixer level */ +if (sti_mixer_set_layer_status (mixer, layer, false)) +DRM_ERROR ("Can not disable %s layer at mixer\n" , +sti_layer_to_str (layer)); + +/* Wait a while to be sure that a Vsync event is received */ +msleep (WAIT_NEXT_VSYNC_MS ); + +/* Then disable layer itself */ +sti_layer_disable (layer); + +drm_vblank_off (crtc->dev, mixer->id); + +/* Disable pixel clock and compo IP clocks */ +if (mixer->id ==STI_MIXER_MAIN ) { +clk_disable_unprepare (compo->clk_pix_main); +clk_disable_unprepare (compo->clk_compo_main); + }else { +clk_disable_unprepare (compo->clk_pix_aux); +clk_disable_unprepare (compo->clk_compo_aux); + } + + compo->enable = false; +} + +static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = { + .dpms = sti_drm_crtc_dpms, + .prepare = sti_drm_crtc_prepare, + .commit = sti_drm_crtc_commit, + .mode_fixup = sti_drm_crtc_mode_fixup, + .mode_set = sti_drm_crtc_mode_set, + .mode_set_base = sti_drm_crtc_mode_set_base, + .load_lut = sti_drm_crtc_load_lut, + .disable = sti_drm_crtc_disable, +}; + +static int sti_drm_crtc_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t page_flip_flags) +{ +struct drm_device *drm_dev = crtc->dev; +struct sti_drm_private *dev_priv = drm_dev->dev_private; +struct drm_framebuffer *old_fb; +struct sti_mixer *mixer =to_sti_mixer (crtc); +unsigned long flags; +int ret =0 ; + +DRM_DEBUG_KMS ("fb %d --> fb %d\n" , crtc->fb->base.id, fb->base.id); + +mutex_lock (&drm_dev->struct_mutex); + + old_fb = crtc->fb; + crtc->fb = fb; + ret =sti_drm_crtc_mode_set_base (crtc, crtc->x, crtc->y, old_fb); +if (ret) { +DRM_ERROR ("failed\n" ); + crtc->fb = old_fb; + goto out; + } + +if (event) { + event->pipe = mixer->id; + + ret =drm_vblank_get (drm_dev, event->pipe); +if (ret) { +DRM_ERROR ("Cannot get vblank\n" ); + goto out; + } + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_add_tail (&event->base.link, &dev_priv->pageflip_evt_list); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + } +out: +mutex_unlock (&drm_dev->struct_mutex); +return ret; +} + +static void sti_drm_crtc_destroy (struct drm_crtc *crtc) +{ +DRM_DEBUG_KMS ("\n" ); + +drm_crtc_cleanup (crtc); +} + +static int sti_drm_crtc_set_property (struct drm_crtc *crtc, +struct drm_property *property, +uint64_t val) +{ +DRM_DEBUG_KMS ("\n" ); + +return 0 ; +} + +int sti_drm_crtc_vblank_cb (struct notifier_block *nb, +unsigned long event,void *data) +{ +struct sti_compositor *compo =container_of (nb, + struct sti_compositor, + vtg_vblank_nb); +struct drm_device *drm_dev; +int *crtc = data; +unsigned long flags; +struct drm_pending_vblank_event *e, *t; +struct sti_drm_private *priv; + + drm_dev = compo->mixer[*crtc]->drm_crtc.dev; + priv = drm_dev->dev_private; + +dev_dbg (drm_dev->dev,"%s\n" , __func__); + +if ((event !=VTG_TOP_FIELD_EVENT ) && + (event !=VTG_BOTTOM_FIELD_EVENT )) { +DRM_ERROR ("unknown event: %lu\n" , event); +return -EINVAL ; + } + +drm_handle_vblank (drm_dev, *crtc); + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_for_each_entry_safe (e, t, &priv->pageflip_evt_list, base.link) { +if (*crtc != e->pipe) +continue ; + +list_del (&e->base.link); +drm_send_vblank_event (drm_dev,-1 , e); +drm_vblank_put (drm_dev, *crtc); + } +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + +return 0 ; +} + +int sti_drm_crtc_enable_vblank (struct drm_device *dev,int crtc) +{ +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; +DRM_DEBUG_DRIVER ("\n" ); + +if (sti_vtg_register_client (crtc, vtg_vblank_nb)) { +DRM_ERROR ("Cannot register VTG notifier\n" ); +return 1 ; + } + +return 0 ; +} + +void sti_drm_crtc_disable_vblank (struct drm_device *dev,int crtc) +{ +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; +unsigned long flags; +struct drm_pending_vblank_event *e, *t; +struct sti_drm_private *priv = dev->dev_private; +DRM_DEBUG_DRIVER ("\n" ); + +if (sti_vtg_unregister_client (crtc, vtg_vblank_nb)) +DRM_DEBUG_DRIVER ("Warning: cannot unregister VTG notifier\n" ); + +/* free the resources of the pending requests */ +spin_lock_irqsave (&dev->event_lock, flags); +list_for_each_entry_safe (e, t, &priv->pageflip_evt_list, base.link) { +if (crtc != e->pipe) +continue ; +list_del (&e->base.link); +drm_vblank_put (dev, crtc); + } +spin_unlock_irqrestore (&dev->event_lock, flags); + +} + +static struct drm_crtc_funcs sti_crtc_funcs = { + .set_config = drm_crtc_helper_set_config, + .page_flip = sti_drm_crtc_page_flip, + .destroy = sti_drm_crtc_destroy, + .set_property = sti_drm_crtc_set_property, +}; + +bool sti_drm_crtc_is_main (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); + +if (mixer->id ==STI_MIXER_MAIN ) +return true; + +return false; +} + +int sti_drm_crtc_init (struct drm_device *drm_dev,struct sti_mixer *mixer) +{ +struct drm_crtc *crtc = &mixer->drm_crtc; +int res; + +dev_dbg (drm_dev->dev,"%s\n" , __func__); + res =drm_crtc_init (drm_dev, crtc, &sti_crtc_funcs); +if (res) { +DRM_ERROR ("Can not initialze CRTC\n" ); +return 1 ; + } + +drm_crtc_helper_add (crtc, &sti_crtc_helper_funcs); + +DRM_DEBUG_DRIVER ("drm CRTC:%d mapped to %s\n" , + crtc->base.id,sti_mixer_to_str (mixer)); + +return 0 ; +}drivers/gpu/drm/sti/sti_drm_crtc.h new file +21
-0@@ -0,0 +1,21 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CRTC_H_ +#define _STI_DRM_CRTC_H_ + +#include <drm/drmP.h> + +#include "sti_mixer.h" + +int sti_drm_crtc_init (struct drm_device *drm_dev,struct sti_mixer *mixer); +int sti_drm_crtc_enable_vblank (struct drm_device *dev,int crtc); +void sti_drm_crtc_disable_vblank (struct drm_device *dev,int crtc); +int sti_drm_crtc_vblank_cb (struct notifier_block *nb, +unsigned long event,void *data); +bool sti_drm_crtc_is_main (struct drm_crtc *drm_crtc); + +#endif drivers/gpu/drm/sti/sti_drm_drv.c new file +466
-0@@ -0,0 +1,466 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/debugfs.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_gem_cma_helper.h> +#include <drm/drm_fb_cma_helper.h> + +#include "sti_drm_drv.h" +#include "sti_drm_crtc.h" +#include "sti_drm_plane.h" +#include "sti_compositor.h" +#include "sti_gdp.h" +#include "sti_drm_encoder.h" +#include "sti_drm_connector.h" +#include "sti_tvout.h" + +#define DRIVER_NAME "sti" +#define DRIVER_DESC "STMicroelectronics SoC DRM" +#define DRIVER_DATE "20130905" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 + +/* platform device pointer for sti drm device. */ +static struct platform_device *sti_drm_pdev; +#ifdef CONFIG_DRM_STI_FBDEV +#define FBDEV_CREATE_DELAY 2000 +struct drm_device *sti_drm_device; + +static void stid_fbdev_create (struct work_struct *dummy) +{ +if (!sti_drm_device) +return ; + +drm_fbdev_cma_init (sti_drm_device,32 , + sti_drm_device->mode_config.num_crtc, + sti_drm_device->mode_config.num_connector); +} + +static DECLARE_DELAYED_WORK(sti_fbdev_work, stid_fbdev_create); +#endif + +static int sti_drm_tvout_init (struct device *dev,void *data) +{ +struct sti_tvout *tvout =dev_get_drvdata (dev); +struct drm_device *drm_dev = data; +struct drm_encoder *encoder; +int i; +struct sti_drm_private *dev_priv = drm_dev->dev_private; + + dev_priv->tvout = tvout; + + tvout->drm_dev = drm_dev; + +/* Register all encoder/connector couples supported by tvout */ +for (i =0 ; i <STI_TVOUT_CONNECTOR_MAX ; i++) { +if (tvout->connector_create[i] !=NULL ) { + encoder =sti_drm_encoder_create (drm_dev, tvout, +1 <<0 , i); +sti_drm_connector_create (drm_dev, tvout, encoder, i); + } + } + +return 0 ; +} + +static int sti_drm_compositor_init (struct device *dev,void *data) +{ +struct sti_compositor *compo =dev_get_drvdata (dev); +struct drm_device *drm_dev = data; +int i, crtc =0 , plane =0 ; +struct sti_drm_private *dev_priv = drm_dev->dev_private; + +dev_dbg (dev,"%s\n" , __func__); + + dev_priv->compo = compo; +INIT_LIST_HEAD (&dev_priv->pageflip_evt_list); + +for (i =0 ; i < compo->nb_mixers; i++) { +if (compo->mixer[i]) { +sti_drm_crtc_init (drm_dev, compo->mixer[i]); + crtc++; + } + } +if (crtc ==0 ) { +DRM_ERROR ("No CRTC available\n" ); +return 1 ; + } + +drm_vblank_init (drm_dev, crtc); +/* Allow usage of vblank without having to call drm_irq_install */ + drm_dev->irq_enabled =1 ; + +for (i =0 ; i < compo->nb_layers; i++) { +if (compo->layer[i]) { +/* Create planes for GDP. +* except GDP0 as it is reserved for CRTC FB */ +enum sti_layer_desc desc = compo->layer[i]->desc; +enum sti_layer_type type = desc &STI_LAYER_TYPE_MASK ; + +if ((type ==STI_GDP ) && (desc !=STI_GDP_0 )) { +sti_drm_plane_init (drm_dev, compo->layer[i], + (1 << crtc) -1 ); + plane++; + } + } + } + +DRM_DEBUG_DRIVER ("Initialized %d DRM CRTC(s) and %d DRM plane(s)\n" , + crtc, plane); +DRM_DEBUG_DRIVER ("DRM plane(s) for VID/VDP not created yet\n" ); + +return 0 ; +} + +static struct drm_mode_config_funcs sti_drm_mode_config_funcs = { + .fb_create = drm_fb_cma_create, +}; + +#ifdef CONFIG_DEBUG_FS +static struct drm_info_list sti_drm_dbg_list[] = { + {"gdp" , sti_gdp_dbg_show,0 }, + {"node" , sti_gdp_node_dbg_show,0 }, + {"mixer" , sti_mixer_dbg_show,0 }, + {"hdmi" , sti_tvout_hdmi_dbg_show,0 ,NULL }, + {"hda" , sti_tvout_hda_dbg_show,0 ,NULL }, +}; + +static int sti_drm_fps_get (void *data,u64 *val) +{ +struct drm_device *dev = data; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +int i; + + *val =0 ; +for (i =0 ; i < compo->nb_layers; i++) + *val |= (compo->layer[i]->fps_info.output) << i; + +return 0 ; +} + +static int sti_drm_fps_set (void *data,u64 val) +{ +struct drm_device *dev = data; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +int i; + +for (i =0 ; i < compo->nb_layers; i++) + compo->layer[i]->fps_info.output = (val >> i) &1 ; + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (sti_drm_fps_fops, + sti_drm_fps_get, sti_drm_fps_set,"%llu\n" ); + +static int sti_drm_debugfs_create (struct dentry *root,struct drm_minor *minor, +const char *name, +const struct file_operations *fops) +{ +struct drm_device *dev = minor->dev; +struct drm_info_node *node; +struct dentry *ent; + + ent =debugfs_create_file (name,S_IRUGO |S_IWUSR , root, dev, fops); +if (IS_ERR (ent)) +return PTR_ERR (ent); + + node =kmalloc (sizeof (struct drm_info_node ),GFP_KERNEL ); +if (node ==NULL ) { +debugfs_remove (ent); +return -ENOMEM ; + } + + node->minor = minor; + node->dent = ent; + node->info_ent = (void *)fops; + +mutex_lock (&minor->debugfs_lock); +list_add (&node->list, &minor->debugfs_list); +mutex_unlock (&minor->debugfs_lock); + +return 0 ; +} + +int sti_drm_dbg_init (struct drm_minor *minor) +{ +int ret; + + ret =sti_drm_debugfs_create (minor->debugfs_root, minor,"fps_show" , + &sti_drm_fps_fops); +if (ret) + goto err; + + ret =drm_debugfs_create_files (sti_drm_dbg_list, +ARRAY_SIZE (sti_drm_dbg_list), + minor->debugfs_root, minor); +if (ret) + goto err; + +DRM_INFO ("%s debugfs installed\n" ,DRIVER_NAME ); + +return ret; +err: +DRM_ERROR ("Cannot install debugfs\n" ); +return ret; +} + +void sti_drm_dbg_cleanup (struct drm_minor *minor) +{ +drm_debugfs_remove_files (sti_drm_dbg_list, +ARRAY_SIZE (sti_drm_dbg_list), minor); + +drm_debugfs_remove_files ((struct drm_info_list *)&sti_drm_fps_fops, +1 , minor); +} +#endif + +static void sti_drm_mode_config_init (struct drm_device *dev) +{ + dev->mode_config.min_width =0 ; + dev->mode_config.min_height =0 ; + +/* +* set max width and height as default value. +* this value would be used to check framebuffer size limitation +* at drm_mode_addfb(). +*/ + dev->mode_config.max_width =STI_MAX_FB_HEIGHT ; + dev->mode_config.max_height =STI_MAX_FB_WIDTH ; + + dev->mode_config.funcs = &sti_drm_mode_config_funcs; +} + +static int sti_drm_load (struct drm_device *dev,unsigned long flags) +{ +struct sti_drm_private *private; +struct device_driver *drv; +int err; + +DRM_INFO ("%s drm_device: %p\n" , __func__, dev); + + private =kzalloc (sizeof (struct sti_drm_private ),GFP_KERNEL ); +if (!private) { +DRM_ERROR ("Failed to allocate private\n" ); +return -ENOMEM ; + } + dev->dev_private = (void *)private; + +drm_mode_config_init (dev); +drm_kms_helper_poll_init (dev); + +sti_drm_mode_config_init (dev); + +/* look for compositors HW */ + drv =driver_find ("sti-compositor" , &platform_bus_type); +if (!drv) { +DRM_ERROR ("No compositor found\n" ); +return -ENOMEM ; + } + err =driver_for_each_device (drv,NULL , dev, sti_drm_compositor_init); +if (err) +DRM_ERROR ("Failed to initialize CRTC\n" ); + +/* look for TVOUT driver */ + drv =driver_find ("sti-tvout" , &platform_bus_type); +if (!drv) { +DRM_ERROR ("No tvout found\n" ); +return -ENOMEM ; + } + err =driver_for_each_device (drv,NULL , dev, sti_drm_tvout_init); +if (err) +DRM_ERROR ("Failed to initialize TVOUT\n" ); + +drm_helper_disable_unused_functions (dev); +#ifdef CONFIG_DRM_STI_FBDEV + sti_drm_device = dev; + +schedule_delayed_work (&sti_fbdev_work, +msecs_to_jiffies (FBDEV_CREATE_DELAY )); +#endif +return err; +} + +static const struct file_operations sti_drm_driver_fops = { + .owner =THIS_MODULE , + .open = drm_open, + .mmap = drm_gem_cma_mmap, + .poll = drm_poll, + .read = drm_read, + .unlocked_ioctl = drm_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .release = drm_release, +}; + +static struct dma_buf *sti_drm_gem_prime_export (struct drm_device *dev, +struct drm_gem_object *obj, +int flags) +{ +/* we want to be able to write in mmapped buffer */ + flags |=O_RDWR ; +return drm_gem_prime_export (dev, obj, flags); +} + +static struct drm_driver sti_drm_driver = { + .driver_features =DRIVER_HAVE_IRQ |DRIVER_MODESET | +DRIVER_GEM |DRIVER_PRIME , + .load = sti_drm_load, + .gem_free_object = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, + .fops = &sti_drm_driver_fops, + + .get_vblank_counter = drm_vblank_count, + .enable_vblank = sti_drm_crtc_enable_vblank, + .disable_vblank = sti_drm_crtc_disable_vblank, + + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = sti_drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + +#ifdef CONFIG_DEBUG_FS + .debugfs_init = sti_drm_dbg_init, + .debugfs_cleanup = sti_drm_dbg_cleanup, +#endif + .name =DRIVER_NAME , + .desc =DRIVER_DESC , + .date =DRIVER_DATE , + .major =DRIVER_MAJOR , + .minor =DRIVER_MINOR , +}; + +static int sti_drm_platform_probe (struct platform_device *pdev) +{ +DRM_INFO ("%s\n" , __func__); + +dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + +return drm_platform_init (&sti_drm_driver, pdev); +} + +static int sti_drm_platform_remove (struct platform_device *pdev) +{ +DRM_INFO ("%s\n" , __func__); + +drm_put_dev (platform_get_drvdata (pdev)); + +return 0 ; +} + +static struct platform_driver sti_drm_platform_driver = { + .probe = sti_drm_platform_probe, + .remove = sti_drm_platform_remove, + .driver = { + .owner =THIS_MODULE , + .name =DRIVER_NAME , + }, +}; + +static int __init sti_drm_init (void ) +{ +int ret; + +DRM_INFO ("%s\n" , __func__); +#ifdef CONFIG_VTAC_STI + ret =platform_driver_register (&sti_vtac_tx_driver); +if (ret <0 ) + goto out_vtac_tx; + ret =platform_driver_register (&sti_vtac_rx_driver); +if (ret <0 ) + goto out_vtac_rx; +#endif +#ifdef CONFIG_VTG_STI + ret =platform_driver_register (&sti_vtg_driver); +if (ret <0 ) + goto out_vtg; +#endif + ret =platform_driver_register (&sti_compositor_driver); +if (ret <0 ) + goto out_compo; + + ret =platform_driver_register (&sti_tvout_driver); +if (ret <0 ) + goto out_tvout; + + ret =platform_driver_register (&sti_hdmi_driver); +if (ret <0 ) + goto out_hdmi; + + ret =platform_driver_register (&sti_hda_driver); +if (ret <0 ) + goto out_hda; + + ret =platform_driver_register (&sti_drm_platform_driver); +if (ret <0 ) + goto out_drm; + + sti_drm_pdev = +platform_device_register_simple (DRIVER_NAME ,-1 ,NULL ,0 ); +if (IS_ERR (sti_drm_pdev)) { + ret =PTR_ERR (sti_drm_pdev); + goto out_drm_device; + } + +return 0 ; + +out_drm_device: +platform_driver_unregister (&sti_drm_platform_driver); +out_drm: +platform_driver_unregister (&sti_hda_driver); +out_hda: +platform_driver_unregister (&sti_hdmi_driver); +out_hdmi: +platform_driver_unregister (&sti_tvout_driver); +out_tvout: +DRM_DEBUG_DRIVER ("Can't register STI DRM platform driver" ); +platform_driver_unregister (&sti_compositor_driver); +out_compo: +#ifdef CONFIG_VTG_STI +platform_driver_unregister (&sti_vtg_driver); +out_vtg: +#endif +#ifdef CONFIG_VTAC_STI +platform_driver_unregister (&sti_vtac_rx_driver); +out_vtac_rx: +platform_driver_unregister (&sti_vtac_tx_driver); +out_vtac_tx: +#endif +return ret; +} + +static void __exit sti_drm_exit(void) +{ +DRM_DEBUG_DRIVER ("\n" ); + +platform_device_unregister (sti_drm_pdev); + +platform_driver_unregister (&sti_drm_platform_driver); +platform_driver_unregister (&sti_compositor_driver); +} + +module_init (sti_drm_init); +module_exit (sti_drm_exit); + +MODULE_AUTHOR ("Benjamin Gaignard <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics SoC DRM driver" ); +MODULE_LICENSE ("GPL" );drivers/gpu/drm/sti/sti_drm_encoder.c new file +201
-0@@ -0,0 +1,201 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_crtc.h" +#include "sti_drm_encoder.h" +#include "sti_tvout.h" + +#define to_sti_encoder (x) container_of(x, struct sti_encoder, drm_encoder) + +#define ENCODER_MAIN_CRTC_MASK (1 << 0) + +/* +* sti specific encoder structure. +* +* @drm_encoder: encoder object. +* @tvout: pointer on tvout driver. +* @type: tvout connector type. +*/ +struct sti_encoder { +struct drm_encoder drm_encoder; +struct sti_tvout *tvout; +enum sti_tvout_connector_type type; +}; + +static void sti_drm_encoder_dpms (struct drm_encoder *encoder,int mode) +{ +} + +static bool sti_drm_encoder_mode_fixup (struct drm_encoder *encoder, +const struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +return true; +} + +static void sti_drm_encoder_mode_set (struct drm_encoder *encoder, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_set_mode (sti_encoder->tvout, mode, + sti_encoder->type); +break ; + } + } +} + +static void sti_drm_encoder_prepare (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_prepare (sti_encoder->tvout, + sti_encoder->type); +break ; + } + } +} + +static void sti_drm_encoder_commit (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_commit (sti_encoder->tvout, + sti_encoder->type, +sti_drm_crtc_is_main (encoder->crtc)); +break ; + } + } +} + +static void sti_drm_encoder_disable (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; +struct drm_connector_helper_funcs *connector_funcs; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { + connector_funcs = connector->helper_private; +if (connector_funcs->best_encoder (connector) == encoder) { +sti_tvout_disable (sti_encoder->tvout, + sti_encoder->type); +break ; + } + } +} + +static const struct drm_encoder_helper_funcs sti_drm_encoder_helper_funcs = { + .dpms = sti_drm_encoder_dpms, + .mode_fixup = sti_drm_encoder_mode_fixup, + .mode_set = sti_drm_encoder_mode_set, + .prepare = sti_drm_encoder_prepare, + .commit = sti_drm_encoder_commit, + .disable = sti_drm_encoder_disable, +}; + +static void sti_drm_encoder_destroy (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_encoder_cleanup (encoder); +kfree (sti_encoder); +} + +static const struct drm_encoder_funcs sti_drm_encoder_funcs = { + .destroy = sti_drm_encoder_destroy, +}; + +struct drm_encoder *sti_drm_encoder_create (struct drm_device *dev, +struct sti_tvout *tvout, +unsigned int possible_crtcs, +enum sti_tvout_connector_type type) +{ +struct sti_encoder *sti_encoder; +struct drm_encoder *encoder; +int encoder_type; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (!dev || !tvout || !possible_crtcs) +return NULL ; + + sti_encoder =kzalloc (sizeof (*sti_encoder),GFP_KERNEL ); +if (!sti_encoder) { +DRM_ERROR ("failed to allocate encoder\n" ); +return NULL ; + } + + sti_encoder->tvout = tvout; + sti_encoder->type = type; + encoder = &sti_encoder->drm_encoder; + encoder->possible_crtcs = possible_crtcs; + +/* HDMI connector only supports main crtc */ +if (type ==STI_TVOUT_CONNECTOR_HDMI ) + encoder->possible_crtcs &=ENCODER_MAIN_CRTC_MASK ; + +/* HD Analog connector may support aux CRTC. Not implemented yet */ +if (type ==STI_TVOUT_CONNECTOR_HDA ) + encoder->possible_crtcs &=ENCODER_MAIN_CRTC_MASK ; + +DRM_DEBUG_DRIVER ("possible_crtcs = 0x%x\n" , encoder->possible_crtcs); + +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : + encoder_type =DRM_MODE_ENCODER_TMDS ; + encoder->possible_clones =1 <<STI_TVOUT_CONNECTOR_HDA ; +break ; +case STI_TVOUT_CONNECTOR_HDA : + encoder_type =DRM_MODE_ENCODER_DAC ; + encoder->possible_clones =1 <<STI_TVOUT_CONNECTOR_HDMI ; +break ; +case STI_TVOUT_CONNECTOR_DENC : + encoder_type =DRM_MODE_ENCODER_DAC ; +break ; +case STI_TVOUT_CONNECTOR_DVO : + encoder_type =DRM_MODE_ENCODER_LVDS ; +break ; +default : + encoder_type =DRM_MODE_ENCODER_NONE ; +break ; + } + +drm_encoder_init (dev, encoder, &sti_drm_encoder_funcs, encoder_type); + +drm_encoder_helper_add (encoder, &sti_drm_encoder_helper_funcs); + +DRM_DEBUG_DRIVER ("encoder has been created\n" ); + +return encoder; +}drivers/gpu/drm/sti/sti_drm_encoder.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_ENCODER_H_ +#define _STI_DRM_ENCODER_H_ + +#include "sti_tvout.h" + +struct drm_encoder *sti_drm_encoder_create (struct drm_device *dev, +struct sti_tvout *tvout,unsigned int possible_crtcs, +enum sti_tvout_connector_type type); + +#endif drivers/gpu/drm/sti/sti_drm_plane.c new file +152
-0@@ -0,0 +1,195 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ +#include "sti_drm_drv.h" +#include "sti_drm_plane.h" +#include "sti_compositor.h" +#include "sti_vtg_utils.h" + +enum sti_layer_desc sti_layer_default_zorder[] = { +STI_GDP_0 , +STI_VID_0 , +STI_GDP_1 , +STI_VID_1 , +STI_GDP_2 , +STI_GDP_3 , +}; + +/* (Background) < GDP0 < VID0 < GDP1 < VID1 < GDP2 < GDP3 < (ForeGround) */ + +static int +sti_drm_update_plane (struct drm_plane *plane,struct drm_crtc *crtc, +struct drm_framebuffer *fb,int crtc_x,int crtc_y, +unsigned int crtc_w,unsigned int crtc_h, +uint32_t src_x,uint32_t src_y, +uint32_t src_w,uint32_t src_h) +{ +struct sti_layer *layer =to_sti_layer (plane); +struct sti_mixer *mixer =to_sti_mixer (crtc); +int res; + +DRM_DEBUG_KMS ("CRTC:%d (%s) drm plane:%d (%s) drm fb:%d\n" , + crtc->base.id,sti_mixer_to_str (mixer), + plane->base.id,sti_layer_to_str (layer), fb->base.id); +DRM_DEBUG_KMS ("(%dx%d)@(%d,%d)\n" , crtc_w, crtc_h, crtc_x, crtc_y); + + res =sti_mixer_set_layer_depth (mixer, layer); +if (res) { +DRM_ERROR ("Can not set layer depth\n" ); +return res; + } + +/* src_x are in 16.16 format. */ + res =sti_layer_prepare (layer, fb, &crtc->mode, mixer->id, + crtc_x, crtc_y, crtc_w, crtc_h, + src_x >>16 , src_y >>16 , + src_w >>16 , src_h >>16 ); +if (res) { +DRM_ERROR ("Layer prepare failed\n" ); +return res; + } + + res =sti_layer_commit (layer); +if (res) { +DRM_ERROR ("Layer commit failed\n" ); +return res; + } + + res =sti_mixer_set_layer_status (mixer, layer, true); +if (res) { +DRM_ERROR ("Can not enable layer at mixer\n" ); +return res; + } + +return 0 ; +} + +static int sti_drm_disable_plane (struct drm_plane *plane) +{ +struct sti_layer *layer; +struct sti_mixer *mixer; +int lay_res, mix_res; + +if (!plane->crtc) { +DRM_DEBUG_DRIVER ("drm plane:%d not enabled\n" , plane->base.id); +return 0 ; + } + layer =to_sti_layer (plane); + mixer =to_sti_mixer (plane->crtc); + +DRM_DEBUG_DRIVER ("CRTC:%d (%s) drm plane:%d (%s)\n" , + plane->crtc->base.id,sti_mixer_to_str (mixer), + plane->base.id,sti_layer_to_str (layer)); + +/* Disable layer at mixer level */ + mix_res =sti_mixer_set_layer_status (mixer, layer, false); +if (mix_res) +DRM_ERROR ("Can not disable layer at mixer\n" ); + +/* Wait a while to be sure that a Vsync event is received */ +msleep (WAIT_NEXT_VSYNC_MS ); + +/* Then disable layer itself */ + lay_res =sti_layer_disable (layer); +if (lay_res) +DRM_ERROR ("Layer disable failed\n" ); + +if (lay_res || mix_res) +return 1 ; +else +return 0 ; +} + +static void sti_drm_plane_destroy (struct drm_plane *plane) +{ +DRM_DEBUG_DRIVER ("\n" ); + +sti_drm_disable_plane (plane); +drm_plane_cleanup (plane); +} + +static int sti_drm_plane_set_property (struct drm_plane *plane, +struct drm_property *property, +uint64_t val) +{ +struct drm_device *dev = plane->dev; +struct sti_drm_private *private = dev->dev_private; +struct sti_layer *layer =to_sti_layer (plane); + +DRM_DEBUG_DRIVER ("\n" ); + +if (property == private->plane_zorder_property) { + layer->zorder = val; +return 0 ; + } + +return -EINVAL ; +} + +static struct drm_plane_funcs sti_drm_plane_funcs = { + .update_plane = sti_drm_update_plane, + .disable_plane = sti_drm_disable_plane, + .destroy = sti_drm_plane_destroy, + .set_property = sti_drm_plane_set_property, +}; + +static void sti_drm_plane_attach_zorder_property (struct drm_plane *plane, +uint64_t default_val) +{ +struct drm_device *dev = plane->dev; +struct sti_drm_private *private = dev->dev_private; +struct drm_property *prop; +struct sti_layer *layer =to_sti_layer (plane); + +dev_dbg (dev->dev,"%s zorder:%llu\n" , __func__, default_val); + + prop = private->plane_zorder_property; +if (!prop) { + prop = drm_property_create_range(dev, 0, "zpos", 0,
drivers/gpu/drm/sti/sti_drm_plane.c line 162
Quoted 10 lines
drivers/gpu/drm/sti/sti_drm_plane.c new file +10
-0+ GAM_MIXER_NB_DEPTH_LEVEL - 1); +if (!prop) +return ; + + private->plane_zorder_property = prop; + } + +drm_object_attach_property (&plane->base, prop, default_val); + layer->zorder = default_val; +}
There's lots of ongoing discussions about standardizing properties a bit better. Especially about plane Z ordering and blending modes. I think it'd be good to hold off on this a bit and participate in the larger discussion about a spec for plane properties until things settle. Especially for a new driver.
I guess for now you could just hardcode Z order how you register the planes.
-Daniel
Quoted 75 lines
drivers/gpu/drm/sti/sti_drm_plane.c new file +33
-0+ +struct drm_plane *sti_drm_plane_init (struct drm_device *dev, +struct sti_layer *layer, +unsigned int possible_crtcs) +{ +int err, i; +uint64_t default_zorder =0 ; + +dev_dbg (dev->dev,"%s\n" , __func__); + + err =drm_plane_init (dev, &layer->plane, possible_crtcs, + &sti_drm_plane_funcs, +sti_layer_get_formats (layer), +sti_layer_get_nb_formats (layer), false); +if (err) { +DRM_ERROR ("Failed to initialize plane\n" ); +return NULL ; + } + +for (i =0 ; i <ARRAY_SIZE (sti_layer_default_zorder); i++) +if (sti_layer_default_zorder[i] == layer->desc) +break ; + + default_zorder = i; + +sti_drm_plane_attach_zorder_property (&layer->plane, default_zorder); + +DRM_DEBUG_DRIVER ("drm plane:%d mapped to %s with zorder:%llu\n" , + layer->plane.base.id, +sti_layer_to_str (layer), default_zorder); + +return &layer->plane; +}drivers/gpu/drm/sti/sti_drm_plane.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_PLANE_H_ +#define _STI_DRM_PLANE_H_ + +#include <drm/drmP.h> +#include "sti_layer.h" + +struct drm_plane *sti_drm_plane_init (struct drm_device *dev, +struct sti_layer *layer,unsigned int possible_crtcs); + +#endif drivers/gpu/drm/sti/sti_vtg_utils.h +2
-0@@ -11,6 +11,8 @@#include <drm/drmP.h> +#define WAIT_NEXT_VSYNC_MS 50/*ms*/ +#define VTG_MAIN 0#define VTG_AUX 1Signature · 6 lines
1.9.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v1 17/19] drm: sti: Add DRM driver itself
For Z order property we have take example on exynos driver and keep the same property name to avoid forking.
I would prefer to not hardcode Z order because we use it to do a kind of composition between graphical planes and video planes. It allow us to manage the Z order of some windows without using software composition.
If you have a link to the plane properties talks we will happy to follow/participate and fix the driver according to what will be defined.
Benjamin
2014-04-11 12:26 GMT+02:00 Daniel Vetter <[email protected]>:
Quoted 1,770 lines · Benjamin Gaignard
Quoted 1,668 lines
Make the link between all the hardware drivers and DRM/KMS interface. Create the driver itself and make it register all the sub-components. Use GEM CMA helpers for buffer allocation.
Signed-off-by Benjamin Gaignard <[email protected]>Signed-off-by Vincent Abriou <[email protected]>Signed-off-by Fabien Dessenne <[email protected]>--- drivers/gpu/drm/sti/Kconfig | 8 + drivers/gpu/drm/sti/Makefile | 28 +- drivers/gpu/drm/sti/sti_compositor.c | 2 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 ++ drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 ++ drivers/gpu/drm/sti/sti_drm_drv.c | 466 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++++++++++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 ++ drivers/gpu/drm/sti/sti_drm_plane.c | 195 +++++++++++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 2 + 13 files changed, 1594 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.hdrivers/gpu/drm/sti/Kconfig +8
-0@@ -1,10 +1,18 @@ config DRM_STI tristate "DRM Support for STMicroelectronics SoC stiH41x Series" depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) + select DRM_KMS_HELPER + select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER help Choose this option to enable DRM on STM stiH41x chipset +config DRM_STI_FBDEV + tristate "DRM frame buffer device for STMicroelectronics SoC stiH41x Serie" + depends on DRM_STI + help + Choose this option to enable FBDEV on top of DRM for STM stiH41x chipset + config VTAC_STI tristate "Video Trafic Advance Communication Rx and Tx for STMicroelectronics SoC stiH41x Series" depends on DRM_STIdrivers/gpu/drm/sti/Makefile +16
-12@@ -1,17 +1,21 @@ ccflags-y := -Iinclude/drm -stidrm-y := \ - sti_compositor.o \ - sti_mixer.o \ - sti_layer.o \ - sti_gdp.o \ - sti_vid.o \ - sti_tvout.o \ - sti_hdmi.o \ - sti_hdmi_tx3g0c55phy.o \ - sti_hdmi_tx3g4c28phy.o \ - sti_hda.o \ - sti_ddc.o +stidrm-y := sti_drm_drv.o \ + sti_drm_crtc.o \ + sti_drm_plane.o \ + sti_drm_connector.o \ + sti_drm_encoder.o \ + sti_compositor.o \ + sti_mixer.o \ + sti_layer.o \ + sti_gdp.o \ + sti_vid.o \ + sti_tvout.o \ + sti_hdmi.o \ + sti_hdmi_tx3g0c55phy.o \ + sti_hdmi_tx3g4c28phy.o \ + sti_hda.o \ + sti_ddc.o obj-$(CONFIG_DRM_STI) += stidrm.o obj-$(CONFIG_VTAC_STI) += sti_vtac_tx.o sti_vtac_rx.odrivers/gpu/drm/sti/sti_compositor.c +2
-0@@ -14,6 +14,7 @@#include "sti_compositor.h" #include "sti_gdp.h" +#include "sti_drm_crtc.h" static const struct of_device_id compositor_match_types[];@@ -98,6 +99,7 @@ static int sti_compositor_probe(struct platform_device *pdev) }DRM_DEBUG_DRIVER ("Compositor %p\n" , compo); compo->dev = dev; + compo->vtg_vblank_nb.notifier_call = sti_drm_crtc_vblank_cb;/* populate data structure depending on compatibility */ BUG_ON (!of_match_node (compositor_match_types, np)->data);drivers/gpu/drm/sti/sti_drm_connector.c new file +195
-0@@ -0,0 +1,195 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_connector.h" +#include "sti_drm_drv.h" + +#define to_sti_connector (x) container_of(x, struct sti_connector, drm_connector) + +/* +* sti specific connector structure +* +* @drm_encoder: connector object +* @encoder: associated encoder +* @tvout: pointer on tvout driver +* @type: tvout connector type +*/ +struct sti_connector { +struct drm_connector drm_connector; +struct drm_encoder *encoder; +struct sti_tvout *tvout; +enum sti_tvout_connector_type type; +}; + +static int sti_drm_connector_get_modes (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +return sti_tvout_get_modes (sti_connector->tvout, sti_connector->type, + connector); +} + +static int sti_drm_connector_mode_valid (struct drm_connector *connector, +struct drm_display_mode *mode) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; +int ret =MODE_BAD ; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (!sti_tvout_check_mode + (sti_connector->tvout, sti_connector->type, mode)) + ret =MODE_OK ; + +return ret; +} + +struct drm_encoder *sti_drm_best_encoder (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +/* Best encoder is the one associated during connector creation */ +return sti_connector->encoder; +} + +static struct drm_connector_helper_funcs sti_drm_connector_helper_funcs = { + .get_modes = sti_drm_connector_get_modes, + .mode_valid = sti_drm_connector_mode_valid, + .best_encoder = sti_drm_best_encoder, +}; + +static void sti_drm_connector_dpms (struct drm_connector *connector,int mode) +{ +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_helper_connector_dpms (connector, mode); +} + +/* get detection status of display device. */ +static enum drm_connector_status +sti_drm_connector_detect (struct drm_connector *connector,bool force) +{ +enum drm_connector_status status = connector_status_disconnected; +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (sti_tvout_connector_detect (sti_connector->tvout, + sti_connector->type)) + status = connector_status_connected; + +return status; +} + +static void sti_drm_connector_destroy (struct drm_connector *connector) +{ +struct sti_connector *sti_connector =to_sti_connector (connector); +struct drm_device *dev = connector->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_sysfs_connector_remove (connector); +drm_connector_cleanup (connector); +kfree (sti_connector); +} + +static struct drm_connector_funcs sti_drm_connector_funcs = { + .dpms = sti_drm_connector_dpms, + .fill_modes = drm_helper_probe_single_connector_modes, + .detect = sti_drm_connector_detect, + .destroy = sti_drm_connector_destroy, +}; + +struct drm_connector *sti_drm_connector_create (struct drm_device *dev, +struct sti_tvout *tvout, +struct drm_encoder *encoder, +enum sti_tvout_connector_type + type) +{ +struct sti_connector *sti_connector; +struct drm_connector *connector; +int connector_type; +int err; + +dev_dbg (dev->dev,"%s\n" , __func__); + +/* Create the tvout connector according to the type */ + tvout->connector[type] = tvout->connector_create[type] (tvout); +if (!tvout->connector[type]) { +DRM_INFO ("%s: failed to create connector (type = %d)\n" , + __func__, type); +return NULL ; + } + + sti_connector =kzalloc (sizeof (*sti_connector),GFP_KERNEL ); +if (!sti_connector) { +DRM_ERROR ("failed to allocate connector\n" ); +return NULL ; + } + + connector = &sti_connector->drm_connector; + +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : + connector_type =DRM_MODE_CONNECTOR_HDMIA ; + connector->polled =DRM_CONNECTOR_POLL_HPD ; +break ; +case STI_TVOUT_CONNECTOR_HDA : + connector_type = DRM_MODE_CONNECTOR_Component; +break ; +case STI_TVOUT_CONNECTOR_DVO : + connector_type =DRM_MODE_CONNECTOR_LVDS ; +break ; +case STI_TVOUT_CONNECTOR_DENC : + connector_type = DRM_MODE_CONNECTOR_Composite; +break ; +default : + connector_type = DRM_MODE_CONNECTOR_Unknown; +break ; + } + +drm_connector_init (dev, connector, &sti_drm_connector_funcs, + connector_type); +drm_connector_helper_add (connector, &sti_drm_connector_helper_funcs); + + err =drm_sysfs_connector_add (connector); +if (err) + goto err_connector; + + sti_connector->tvout = tvout; + sti_connector->encoder = encoder; + sti_connector->type = type; + + err =drm_mode_connector_attach_encoder (connector, encoder); +if (err) { +DRM_ERROR ("Failed to attach a connector to a encoder\n" ); + goto err_sysfs; + } + +DRM_DEBUG_DRIVER ("Connector has been created\n" ); + +return connector; + +err_sysfs: +drm_sysfs_connector_remove (connector); +err_connector: +drm_connector_cleanup (connector); +kfree (sti_connector); +return NULL ; +}drivers/gpu/drm/sti/sti_drm_connector.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CONNECTOR_H_ +#define _STI_DRM_CONNECTOR_H_ + +#include "sti_tvout.h" + +struct drm_connector *sti_drm_connector_create (struct drm_device *dev, +struct sti_tvout *tvout,struct drm_encoder *encoder, +enum sti_tvout_connector_type type); + +#endif drivers/gpu/drm/sti/sti_drm_crtc.c new file +440
-0@@ -0,0 +1,440 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <linux/clk.h> + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_drv.h" +#include "sti_drm_crtc.h" +#include "sti_compositor.h" +#include "sti_vtg_utils.h" + +static void sti_drm_crtc_dpms (struct drm_crtc *crtc,int mode) +{ +DRM_DEBUG_KMS ("\n" ); +} + +static void sti_drm_crtc_prepare (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); + + compo->enable = true; + +/* Prepare and enable the compo IP clock */ +if (mixer->id ==STI_MIXER_MAIN ) { +if (clk_prepare_enable (compo->clk_compo_main)) +DRM_INFO ("Failed to prepare/enable compo_main clk\n" ); + }else { +if (clk_prepare_enable (compo->clk_compo_aux)) +DRM_INFO ("Failed to prepare/enable compo_aux clk\n" ); + } +} + +static void sti_drm_crtc_commit (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; + +dev_dbg (dev,"%s\n" , __func__); +if ((!mixer || !compo)) { +DRM_ERROR ("Can not find mixer or compositor)\n" ); +return ; + } + +/* Find GDP0 which is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (layer) +sti_layer_commit (layer); +else +DRM_ERROR ("Can not find CRTC dedicated plane (GDP0)\n" ); + +/* Enable layer on mixer */ +if (sti_mixer_set_layer_status (mixer, layer, true)) +DRM_ERROR ("Can not enable layer at mixer\n" ); +} + +static bool sti_drm_crtc_mode_fixup (struct drm_crtc *crtc, +const struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +/* accept the provided drm_display_mode, do not fix it up */ +dev_dbg (crtc->dev->dev,"%s\n" , __func__); +return true; +} + +static int +sti_drm_crtc_mode_set (struct drm_crtc *crtc,struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode,int x,int y, +struct drm_framebuffer *old_fb) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; +struct clk *clk; +int rate = mode->clock *1000 ; +int res; +unsigned int w, h; + +DRM_DEBUG_KMS ("CRTC:%d (%s) fb:%d mode:%d (%s)\n" , + crtc->base.id,sti_mixer_to_str (mixer), + crtc->fb->base.id, mode->base.id, mode->name); + +DRM_DEBUG_KMS ("%d %d %d %d %d %d %d %d %d %d 0x%x 0x%x\n" , + mode->vrefresh, mode->clock, + mode->hdisplay, + mode->hsync_start, mode->hsync_end, + mode->htotal, + mode->vdisplay, + mode->vsync_start, mode->vsync_end, + mode->vtotal, mode->type, mode->flags); + +/* Set rate and prepare/enable pixel clock */ +if (mixer->id ==STI_MIXER_MAIN ) + clk = compo->clk_pix_main; +else + clk = compo->clk_pix_aux; + + res =clk_set_rate (clk, rate); +if (res <0 ) { +DRM_ERROR ("Cannot set rate (%dHz) for pix clk\n" , rate); +return 1 ; + } +if (clk_prepare_enable (clk)) { +DRM_ERROR ("Failed to prepare/enable pix clk\n" ); +return 1 ; + } + +sti_vtg_setconfig (mixer->id ==STI_MIXER_MAIN ?VTG_MAIN :VTG_AUX , + &crtc->mode); + +/* GDP0 is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Can not find GDP0)\n" ); +return 1 ; + } + +/* copy the mode data adjusted by mode_fixup() into crtc->mode +* so that hardware can be set to proper mode */ +memcpy (&crtc->mode, adjusted_mode,sizeof (*adjusted_mode)); + + res =sti_mixer_set_layer_depth (mixer, layer); +if (res) { +DRM_ERROR ("Can not set layer depth\n" ); +return 1 ; + } + res =sti_mixer_active_video_area (mixer, &crtc->mode); +if (res) { +DRM_ERROR ("Can not set active video area\n" ); +return 1 ; + } + +if ((mode->hdisplay != crtc->fb->width) || + (mode->vdisplay != crtc->fb->height)) +DRM_DEBUG_KMS ("WARNING: fb and display mode sizes differ\n" ); + + w = crtc->fb->width - x; + h = crtc->fb->height - y; + +if ((w <=0 ) || (h <=0 )) { +DRM_ERROR ("Coordinates outside FB\n" ); +return -EINVAL ; + } + +return sti_layer_prepare (layer, crtc->fb, &crtc->mode, mixer->id, +0 ,0 , w, h, x, y, w, h); +} + +static int sti_drm_crtc_mode_set_base (struct drm_crtc *crtc,int x,int y, +struct drm_framebuffer *old_fb) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; +unsigned int w, h; +int ret =0 ; + +DRM_DEBUG_KMS ("CRTC:%d (%s) fb:%d (%d,%d)\n" , + crtc->base.id,sti_mixer_to_str (mixer), + crtc->fb->base.id, x, y); + +/* GDP0 is reserved to the CRTC FB */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Can not find GDP0)\n" ); + ret =-1 ; + goto out; + } + + w = crtc->fb->width - crtc->x; + h = crtc->fb->height - crtc->y; + +if ((w <=0 ) || (h <=0 )) { +DRM_ERROR ("Coordinates outside FB\n" ); + ret = -EINVAL ; + goto out; + } + + ret =sti_layer_prepare (layer, crtc->fb, &crtc->mode, mixer->id, +0 ,0 , w, h, + crtc->x, crtc->y, w, h); +if (ret) { +DRM_ERROR ("Can not prepare layer\n" ); + goto out; + } + +sti_drm_crtc_commit (crtc); +out: +return ret; +} + +static void sti_drm_crtc_load_lut (struct drm_crtc *crtc) +{ +dev_dbg (crtc->dev->dev,"%s\n" , __func__); +} + +static void sti_drm_crtc_disable (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); +struct device *dev = mixer->dev; +struct sti_compositor *compo =dev_get_drvdata (dev); +struct sti_layer *layer; + +if (!compo->enable) +return ; + +DRM_DEBUG_KMS ("CRTC:%d (%s)\n" , crtc->base.id,sti_mixer_to_str (mixer)); + +/* Disable Background */ +sti_mixer_set_background_status (mixer, false); + +/* Disable GDP0 */ + layer =sti_layer_find_layer (compo->layer,STI_GDP_0 ); +if (!layer) { +DRM_ERROR ("Cannot find GDP0\n" ); +return ; + } + +/* Disable layer at mixer level */ +if (sti_mixer_set_layer_status (mixer, layer, false)) +DRM_ERROR ("Can not disable %s layer at mixer\n" , +sti_layer_to_str (layer)); + +/* Wait a while to be sure that a Vsync event is received */ +msleep (WAIT_NEXT_VSYNC_MS ); + +/* Then disable layer itself */ +sti_layer_disable (layer); + +drm_vblank_off (crtc->dev, mixer->id); + +/* Disable pixel clock and compo IP clocks */ +if (mixer->id ==STI_MIXER_MAIN ) { +clk_disable_unprepare (compo->clk_pix_main); +clk_disable_unprepare (compo->clk_compo_main); + }else { +clk_disable_unprepare (compo->clk_pix_aux); +clk_disable_unprepare (compo->clk_compo_aux); + } + + compo->enable = false; +} + +static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = { + .dpms = sti_drm_crtc_dpms, + .prepare = sti_drm_crtc_prepare, + .commit = sti_drm_crtc_commit, + .mode_fixup = sti_drm_crtc_mode_fixup, + .mode_set = sti_drm_crtc_mode_set, + .mode_set_base = sti_drm_crtc_mode_set_base, + .load_lut = sti_drm_crtc_load_lut, + .disable = sti_drm_crtc_disable, +}; + +static int sti_drm_crtc_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t page_flip_flags) +{ +struct drm_device *drm_dev = crtc->dev; +struct sti_drm_private *dev_priv = drm_dev->dev_private; +struct drm_framebuffer *old_fb; +struct sti_mixer *mixer =to_sti_mixer (crtc); +unsigned long flags; +int ret =0 ; + +DRM_DEBUG_KMS ("fb %d --> fb %d\n" , crtc->fb->base.id, fb->base.id); + +mutex_lock (&drm_dev->struct_mutex); + + old_fb = crtc->fb; + crtc->fb = fb; + ret =sti_drm_crtc_mode_set_base (crtc, crtc->x, crtc->y, old_fb); +if (ret) { +DRM_ERROR ("failed\n" ); + crtc->fb = old_fb; + goto out; + } + +if (event) { + event->pipe = mixer->id; + + ret =drm_vblank_get (drm_dev, event->pipe); +if (ret) { +DRM_ERROR ("Cannot get vblank\n" ); + goto out; + } + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_add_tail (&event->base.link, &dev_priv->pageflip_evt_list); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + } +out: +mutex_unlock (&drm_dev->struct_mutex); +return ret; +} + +static void sti_drm_crtc_destroy (struct drm_crtc *crtc) +{ +DRM_DEBUG_KMS ("\n" ); + +drm_crtc_cleanup (crtc); +} + +static int sti_drm_crtc_set_property (struct drm_crtc *crtc, +struct drm_property *property, +uint64_t val) +{ +DRM_DEBUG_KMS ("\n" ); + +return 0 ; +} + +int sti_drm_crtc_vblank_cb (struct notifier_block *nb, +unsigned long event,void *data) +{ +struct sti_compositor *compo =container_of (nb, + struct sti_compositor, + vtg_vblank_nb); +struct drm_device *drm_dev; +int *crtc = data; +unsigned long flags; +struct drm_pending_vblank_event *e, *t; +struct sti_drm_private *priv; + + drm_dev = compo->mixer[*crtc]->drm_crtc.dev; + priv = drm_dev->dev_private; + +dev_dbg (drm_dev->dev,"%s\n" , __func__); + +if ((event !=VTG_TOP_FIELD_EVENT ) && + (event !=VTG_BOTTOM_FIELD_EVENT )) { +DRM_ERROR ("unknown event: %lu\n" , event); +return -EINVAL ; + } + +drm_handle_vblank (drm_dev, *crtc); + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_for_each_entry_safe (e, t, &priv->pageflip_evt_list, base.link) { +if (*crtc != e->pipe) +continue ; + +list_del (&e->base.link); +drm_send_vblank_event (drm_dev,-1 , e); +drm_vblank_put (drm_dev, *crtc); + } +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + +return 0 ; +} + +int sti_drm_crtc_enable_vblank (struct drm_device *dev,int crtc) +{ +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; +DRM_DEBUG_DRIVER ("\n" ); + +if (sti_vtg_register_client (crtc, vtg_vblank_nb)) { +DRM_ERROR ("Cannot register VTG notifier\n" ); +return 1 ; + } + +return 0 ; +} + +void sti_drm_crtc_disable_vblank (struct drm_device *dev,int crtc) +{ +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; +unsigned long flags; +struct drm_pending_vblank_event *e, *t; +struct sti_drm_private *priv = dev->dev_private; +DRM_DEBUG_DRIVER ("\n" ); + +if (sti_vtg_unregister_client (crtc, vtg_vblank_nb)) +DRM_DEBUG_DRIVER ("Warning: cannot unregister VTG notifier\n" ); + +/* free the resources of the pending requests */ +spin_lock_irqsave (&dev->event_lock, flags); +list_for_each_entry_safe (e, t, &priv->pageflip_evt_list, base.link) { +if (crtc != e->pipe) +continue ; +list_del (&e->base.link); +drm_vblank_put (dev, crtc); + } +spin_unlock_irqrestore (&dev->event_lock, flags); + +} + +static struct drm_crtc_funcs sti_crtc_funcs = { + .set_config = drm_crtc_helper_set_config, + .page_flip = sti_drm_crtc_page_flip, + .destroy = sti_drm_crtc_destroy, + .set_property = sti_drm_crtc_set_property, +}; + +bool sti_drm_crtc_is_main (struct drm_crtc *crtc) +{ +struct sti_mixer *mixer =to_sti_mixer (crtc); + +if (mixer->id ==STI_MIXER_MAIN ) +return true; + +return false; +} + +int sti_drm_crtc_init (struct drm_device *drm_dev,struct sti_mixer *mixer) +{ +struct drm_crtc *crtc = &mixer->drm_crtc; +int res; + +dev_dbg (drm_dev->dev,"%s\n" , __func__); + res =drm_crtc_init (drm_dev, crtc, &sti_crtc_funcs); +if (res) { +DRM_ERROR ("Can not initialze CRTC\n" ); +return 1 ; + } + +drm_crtc_helper_add (crtc, &sti_crtc_helper_funcs); + +DRM_DEBUG_DRIVER ("drm CRTC:%d mapped to %s\n" , + crtc->base.id,sti_mixer_to_str (mixer)); + +return 0 ; +}drivers/gpu/drm/sti/sti_drm_crtc.h new file +21
-0@@ -0,0 +1,21 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_CRTC_H_ +#define _STI_DRM_CRTC_H_ + +#include <drm/drmP.h> + +#include "sti_mixer.h" + +int sti_drm_crtc_init (struct drm_device *drm_dev,struct sti_mixer *mixer); +int sti_drm_crtc_enable_vblank (struct drm_device *dev,int crtc); +void sti_drm_crtc_disable_vblank (struct drm_device *dev,int crtc); +int sti_drm_crtc_vblank_cb (struct notifier_block *nb, +unsigned long event,void *data); +bool sti_drm_crtc_is_main (struct drm_crtc *drm_crtc); + +#endif drivers/gpu/drm/sti/sti_drm_drv.c new file +466
-0@@ -0,0 +1,466 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/debugfs.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_gem_cma_helper.h> +#include <drm/drm_fb_cma_helper.h> + +#include "sti_drm_drv.h" +#include "sti_drm_crtc.h" +#include "sti_drm_plane.h" +#include "sti_compositor.h" +#include "sti_gdp.h" +#include "sti_drm_encoder.h" +#include "sti_drm_connector.h" +#include "sti_tvout.h" + +#define DRIVER_NAME "sti" +#define DRIVER_DESC "STMicroelectronics SoC DRM" +#define DRIVER_DATE "20130905" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 + +/* platform device pointer for sti drm device. */ +static struct platform_device *sti_drm_pdev; +#ifdef CONFIG_DRM_STI_FBDEV +#define FBDEV_CREATE_DELAY 2000 +struct drm_device *sti_drm_device; + +static void stid_fbdev_create (struct work_struct *dummy) +{ +if (!sti_drm_device) +return ; + +drm_fbdev_cma_init (sti_drm_device,32 , + sti_drm_device->mode_config.num_crtc, + sti_drm_device->mode_config.num_connector); +} + +static DECLARE_DELAYED_WORK(sti_fbdev_work, stid_fbdev_create); +#endif + +static int sti_drm_tvout_init (struct device *dev,void *data) +{ +struct sti_tvout *tvout =dev_get_drvdata (dev); +struct drm_device *drm_dev = data; +struct drm_encoder *encoder; +int i; +struct sti_drm_private *dev_priv = drm_dev->dev_private; + + dev_priv->tvout = tvout; + + tvout->drm_dev = drm_dev; + +/* Register all encoder/connector couples supported by tvout */ +for (i =0 ; i <STI_TVOUT_CONNECTOR_MAX ; i++) { +if (tvout->connector_create[i] !=NULL ) { + encoder =sti_drm_encoder_create (drm_dev, tvout, +1 <<0 , i); +sti_drm_connector_create (drm_dev, tvout, encoder, i); + } + } + +return 0 ; +} + +static int sti_drm_compositor_init (struct device *dev,void *data) +{ +struct sti_compositor *compo =dev_get_drvdata (dev); +struct drm_device *drm_dev = data; +int i, crtc =0 , plane =0 ; +struct sti_drm_private *dev_priv = drm_dev->dev_private; + +dev_dbg (dev,"%s\n" , __func__); + + dev_priv->compo = compo; +INIT_LIST_HEAD (&dev_priv->pageflip_evt_list); + +for (i =0 ; i < compo->nb_mixers; i++) { +if (compo->mixer[i]) { +sti_drm_crtc_init (drm_dev, compo->mixer[i]); + crtc++; + } + } +if (crtc ==0 ) { +DRM_ERROR ("No CRTC available\n" ); +return 1 ; + } + +drm_vblank_init (drm_dev, crtc); +/* Allow usage of vblank without having to call drm_irq_install */ + drm_dev->irq_enabled =1 ; + +for (i =0 ; i < compo->nb_layers; i++) { +if (compo->layer[i]) { +/* Create planes for GDP. +* except GDP0 as it is reserved for CRTC FB */ +enum sti_layer_desc desc = compo->layer[i]->desc; +enum sti_layer_type type = desc &STI_LAYER_TYPE_MASK ; + +if ((type ==STI_GDP ) && (desc !=STI_GDP_0 )) { +sti_drm_plane_init (drm_dev, compo->layer[i], + (1 << crtc) -1 ); + plane++; + } + } + } + +DRM_DEBUG_DRIVER ("Initialized %d DRM CRTC(s) and %d DRM plane(s)\n" , + crtc, plane); +DRM_DEBUG_DRIVER ("DRM plane(s) for VID/VDP not created yet\n" ); + +return 0 ; +} + +static struct drm_mode_config_funcs sti_drm_mode_config_funcs = { + .fb_create = drm_fb_cma_create, +}; + +#ifdef CONFIG_DEBUG_FS +static struct drm_info_list sti_drm_dbg_list[] = { + {"gdp" , sti_gdp_dbg_show,0 }, + {"node" , sti_gdp_node_dbg_show,0 }, + {"mixer" , sti_mixer_dbg_show,0 }, + {"hdmi" , sti_tvout_hdmi_dbg_show,0 ,NULL }, + {"hda" , sti_tvout_hda_dbg_show,0 ,NULL }, +}; + +static int sti_drm_fps_get (void *data,u64 *val) +{ +struct drm_device *dev = data; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +int i; + + *val =0 ; +for (i =0 ; i < compo->nb_layers; i++) + *val |= (compo->layer[i]->fps_info.output) << i; + +return 0 ; +} + +static int sti_drm_fps_set (void *data,u64 val) +{ +struct drm_device *dev = data; +struct sti_drm_private *dev_priv = dev->dev_private; +struct sti_compositor *compo = dev_priv->compo; +int i; + +for (i =0 ; i < compo->nb_layers; i++) + compo->layer[i]->fps_info.output = (val >> i) &1 ; + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (sti_drm_fps_fops, + sti_drm_fps_get, sti_drm_fps_set,"%llu\n" ); + +static int sti_drm_debugfs_create (struct dentry *root,struct drm_minor *minor, +const char *name, +const struct file_operations *fops) +{ +struct drm_device *dev = minor->dev; +struct drm_info_node *node; +struct dentry *ent; + + ent =debugfs_create_file (name,S_IRUGO |S_IWUSR , root, dev, fops); +if (IS_ERR (ent)) +return PTR_ERR (ent); + + node =kmalloc (sizeof (struct drm_info_node ),GFP_KERNEL ); +if (node ==NULL ) { +debugfs_remove (ent); +return -ENOMEM ; + } + + node->minor = minor; + node->dent = ent; + node->info_ent = (void *)fops; + +mutex_lock (&minor->debugfs_lock); +list_add (&node->list, &minor->debugfs_list); +mutex_unlock (&minor->debugfs_lock); + +return 0 ; +} + +int sti_drm_dbg_init (struct drm_minor *minor) +{ +int ret; + + ret =sti_drm_debugfs_create (minor->debugfs_root, minor,"fps_show" , + &sti_drm_fps_fops); +if (ret) + goto err; + + ret =drm_debugfs_create_files (sti_drm_dbg_list, +ARRAY_SIZE (sti_drm_dbg_list), + minor->debugfs_root, minor); +if (ret) + goto err; + +DRM_INFO ("%s debugfs installed\n" ,DRIVER_NAME ); + +return ret; +err: +DRM_ERROR ("Cannot install debugfs\n" ); +return ret; +} + +void sti_drm_dbg_cleanup (struct drm_minor *minor) +{ +drm_debugfs_remove_files (sti_drm_dbg_list, +ARRAY_SIZE (sti_drm_dbg_list), minor); + +drm_debugfs_remove_files ((struct drm_info_list *)&sti_drm_fps_fops, +1 , minor); +} +#endif + +static void sti_drm_mode_config_init (struct drm_device *dev) +{ + dev->mode_config.min_width =0 ; + dev->mode_config.min_height =0 ; + +/* +* set max width and height as default value. +* this value would be used to check framebuffer size limitation +* at drm_mode_addfb(). +*/ + dev->mode_config.max_width =STI_MAX_FB_HEIGHT ; + dev->mode_config.max_height =STI_MAX_FB_WIDTH ; + + dev->mode_config.funcs = &sti_drm_mode_config_funcs; +} + +static int sti_drm_load (struct drm_device *dev,unsigned long flags) +{ +struct sti_drm_private *private; +struct device_driver *drv; +int err; + +DRM_INFO ("%s drm_device: %p\n" , __func__, dev); + + private =kzalloc (sizeof (struct sti_drm_private ),GFP_KERNEL ); +if (!private) { +DRM_ERROR ("Failed to allocate private\n" ); +return -ENOMEM ; + } + dev->dev_private = (void *)private; + +drm_mode_config_init (dev); +drm_kms_helper_poll_init (dev); + +sti_drm_mode_config_init (dev); + +/* look for compositors HW */ + drv =driver_find ("sti-compositor" , &platform_bus_type); +if (!drv) { +DRM_ERROR ("No compositor found\n" ); +return -ENOMEM ; + } + err =driver_for_each_device (drv,NULL , dev, sti_drm_compositor_init); +if (err) +DRM_ERROR ("Failed to initialize CRTC\n" ); + +/* look for TVOUT driver */ + drv =driver_find ("sti-tvout" , &platform_bus_type); +if (!drv) { +DRM_ERROR ("No tvout found\n" ); +return -ENOMEM ; + } + err =driver_for_each_device (drv,NULL , dev, sti_drm_tvout_init); +if (err) +DRM_ERROR ("Failed to initialize TVOUT\n" ); + +drm_helper_disable_unused_functions (dev); +#ifdef CONFIG_DRM_STI_FBDEV + sti_drm_device = dev; + +schedule_delayed_work (&sti_fbdev_work, +msecs_to_jiffies (FBDEV_CREATE_DELAY )); +#endif +return err; +} + +static const struct file_operations sti_drm_driver_fops = { + .owner =THIS_MODULE , + .open = drm_open, + .mmap = drm_gem_cma_mmap, + .poll = drm_poll, + .read = drm_read, + .unlocked_ioctl = drm_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .release = drm_release, +}; + +static struct dma_buf *sti_drm_gem_prime_export (struct drm_device *dev, +struct drm_gem_object *obj, +int flags) +{ +/* we want to be able to write in mmapped buffer */ + flags |=O_RDWR ; +return drm_gem_prime_export (dev, obj, flags); +} + +static struct drm_driver sti_drm_driver = { + .driver_features =DRIVER_HAVE_IRQ |DRIVER_MODESET | +DRIVER_GEM |DRIVER_PRIME , + .load = sti_drm_load, + .gem_free_object = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, + .fops = &sti_drm_driver_fops, + + .get_vblank_counter = drm_vblank_count, + .enable_vblank = sti_drm_crtc_enable_vblank, + .disable_vblank = sti_drm_crtc_disable_vblank, + + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = sti_drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + +#ifdef CONFIG_DEBUG_FS + .debugfs_init = sti_drm_dbg_init, + .debugfs_cleanup = sti_drm_dbg_cleanup, +#endif + .name =DRIVER_NAME , + .desc =DRIVER_DESC , + .date =DRIVER_DATE , + .major =DRIVER_MAJOR , + .minor =DRIVER_MINOR , +}; + +static int sti_drm_platform_probe (struct platform_device *pdev) +{ +DRM_INFO ("%s\n" , __func__); + +dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + +return drm_platform_init (&sti_drm_driver, pdev); +} + +static int sti_drm_platform_remove (struct platform_device *pdev) +{ +DRM_INFO ("%s\n" , __func__); + +drm_put_dev (platform_get_drvdata (pdev)); + +return 0 ; +} + +static struct platform_driver sti_drm_platform_driver = { + .probe = sti_drm_platform_probe, + .remove = sti_drm_platform_remove, + .driver = { + .owner =THIS_MODULE , + .name =DRIVER_NAME , + }, +}; + +static int __init sti_drm_init (void ) +{ +int ret; + +DRM_INFO ("%s\n" , __func__); +#ifdef CONFIG_VTAC_STI + ret =platform_driver_register (&sti_vtac_tx_driver); +if (ret <0 ) + goto out_vtac_tx; + ret =platform_driver_register (&sti_vtac_rx_driver); +if (ret <0 ) + goto out_vtac_rx; +#endif +#ifdef CONFIG_VTG_STI + ret =platform_driver_register (&sti_vtg_driver); +if (ret <0 ) + goto out_vtg; +#endif + ret =platform_driver_register (&sti_compositor_driver); +if (ret <0 ) + goto out_compo; + + ret =platform_driver_register (&sti_tvout_driver); +if (ret <0 ) + goto out_tvout; + + ret =platform_driver_register (&sti_hdmi_driver); +if (ret <0 ) + goto out_hdmi; + + ret =platform_driver_register (&sti_hda_driver); +if (ret <0 ) + goto out_hda; + + ret =platform_driver_register (&sti_drm_platform_driver); +if (ret <0 ) + goto out_drm; + + sti_drm_pdev = +platform_device_register_simple (DRIVER_NAME ,-1 ,NULL ,0 ); +if (IS_ERR (sti_drm_pdev)) { + ret =PTR_ERR (sti_drm_pdev); + goto out_drm_device; + } + +return 0 ; + +out_drm_device: +platform_driver_unregister (&sti_drm_platform_driver); +out_drm: +platform_driver_unregister (&sti_hda_driver); +out_hda: +platform_driver_unregister (&sti_hdmi_driver); +out_hdmi: +platform_driver_unregister (&sti_tvout_driver); +out_tvout: +DRM_DEBUG_DRIVER ("Can't register STI DRM platform driver" ); +platform_driver_unregister (&sti_compositor_driver); +out_compo: +#ifdef CONFIG_VTG_STI +platform_driver_unregister (&sti_vtg_driver); +out_vtg: +#endif +#ifdef CONFIG_VTAC_STI +platform_driver_unregister (&sti_vtac_rx_driver); +out_vtac_rx: +platform_driver_unregister (&sti_vtac_tx_driver); +out_vtac_tx: +#endif +return ret; +} + +static void __exit sti_drm_exit(void) +{ +DRM_DEBUG_DRIVER ("\n" ); + +platform_device_unregister (sti_drm_pdev); + +platform_driver_unregister (&sti_drm_platform_driver); +platform_driver_unregister (&sti_compositor_driver); +} + +module_init (sti_drm_init); +module_exit (sti_drm_exit); + +MODULE_AUTHOR ("Benjamin Gaignard <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics SoC DRM driver" ); +MODULE_LICENSE ("GPL" );drivers/gpu/drm/sti/sti_drm_encoder.c new file +201
-0@@ -0,0 +1,201 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <drm/drmP.h> +#include <drm/drm_crtc_helper.h> + +#include "sti_drm_crtc.h" +#include "sti_drm_encoder.h" +#include "sti_tvout.h" + +#define to_sti_encoder (x) container_of(x, struct sti_encoder, drm_encoder) + +#define ENCODER_MAIN_CRTC_MASK (1 << 0) + +/* +* sti specific encoder structure. +* +* @drm_encoder: encoder object. +* @tvout: pointer on tvout driver. +* @type: tvout connector type. +*/ +struct sti_encoder { +struct drm_encoder drm_encoder; +struct sti_tvout *tvout; +enum sti_tvout_connector_type type; +}; + +static void sti_drm_encoder_dpms (struct drm_encoder *encoder,int mode) +{ +} + +static bool sti_drm_encoder_mode_fixup (struct drm_encoder *encoder, +const struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +return true; +} + +static void sti_drm_encoder_mode_set (struct drm_encoder *encoder, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_set_mode (sti_encoder->tvout, mode, + sti_encoder->type); +break ; + } + } +} + +static void sti_drm_encoder_prepare (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_prepare (sti_encoder->tvout, + sti_encoder->type); +break ; + } + } +} + +static void sti_drm_encoder_commit (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (connector->encoder == encoder) { +sti_tvout_commit (sti_encoder->tvout, + sti_encoder->type, +sti_drm_crtc_is_main (encoder->crtc)); +break ; + } + } +} + +static void sti_drm_encoder_disable (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; +struct drm_connector *connector; +struct drm_connector_helper_funcs *connector_funcs; + +dev_dbg (dev->dev,"%s\n" , __func__); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { + connector_funcs = connector->helper_private; +if (connector_funcs->best_encoder (connector) == encoder) { +sti_tvout_disable (sti_encoder->tvout, + sti_encoder->type); +break ; + } + } +} + +static const struct drm_encoder_helper_funcs sti_drm_encoder_helper_funcs = { + .dpms = sti_drm_encoder_dpms, + .mode_fixup = sti_drm_encoder_mode_fixup, + .mode_set = sti_drm_encoder_mode_set, + .prepare = sti_drm_encoder_prepare, + .commit = sti_drm_encoder_commit, + .disable = sti_drm_encoder_disable, +}; + +static void sti_drm_encoder_destroy (struct drm_encoder *encoder) +{ +struct sti_encoder *sti_encoder =to_sti_encoder (encoder); +struct drm_device *dev = encoder->dev; + +dev_dbg (dev->dev,"%s\n" , __func__); + +drm_encoder_cleanup (encoder); +kfree (sti_encoder); +} + +static const struct drm_encoder_funcs sti_drm_encoder_funcs = { + .destroy = sti_drm_encoder_destroy, +}; + +struct drm_encoder *sti_drm_encoder_create (struct drm_device *dev, +struct sti_tvout *tvout, +unsigned int possible_crtcs, +enum sti_tvout_connector_type type) +{ +struct sti_encoder *sti_encoder; +struct drm_encoder *encoder; +int encoder_type; + +dev_dbg (dev->dev,"%s\n" , __func__); + +if (!dev || !tvout || !possible_crtcs) +return NULL ; + + sti_encoder =kzalloc (sizeof (*sti_encoder),GFP_KERNEL ); +if (!sti_encoder) { +DRM_ERROR ("failed to allocate encoder\n" ); +return NULL ; + } + + sti_encoder->tvout = tvout; + sti_encoder->type = type; + encoder = &sti_encoder->drm_encoder; + encoder->possible_crtcs = possible_crtcs; + +/* HDMI connector only supports main crtc */ +if (type ==STI_TVOUT_CONNECTOR_HDMI ) + encoder->possible_crtcs &=ENCODER_MAIN_CRTC_MASK ; + +/* HD Analog connector may support aux CRTC. Not implemented yet */ +if (type ==STI_TVOUT_CONNECTOR_HDA ) + encoder->possible_crtcs &=ENCODER_MAIN_CRTC_MASK ; + +DRM_DEBUG_DRIVER ("possible_crtcs = 0x%x\n" , encoder->possible_crtcs); + +switch (type) { +case STI_TVOUT_CONNECTOR_HDMI : + encoder_type =DRM_MODE_ENCODER_TMDS ; + encoder->possible_clones =1 <<STI_TVOUT_CONNECTOR_HDA ; +break ; +case STI_TVOUT_CONNECTOR_HDA : + encoder_type =DRM_MODE_ENCODER_DAC ; + encoder->possible_clones =1 <<STI_TVOUT_CONNECTOR_HDMI ; +break ; +case STI_TVOUT_CONNECTOR_DENC : + encoder_type =DRM_MODE_ENCODER_DAC ; +break ; +case STI_TVOUT_CONNECTOR_DVO : + encoder_type =DRM_MODE_ENCODER_LVDS ; +break ; +default : + encoder_type =DRM_MODE_ENCODER_NONE ; +break ; + } + +drm_encoder_init (dev, encoder, &sti_drm_encoder_funcs, encoder_type); + +drm_encoder_helper_add (encoder, &sti_drm_encoder_helper_funcs); + +DRM_DEBUG_DRIVER ("encoder has been created\n" ); + +return encoder; +}drivers/gpu/drm/sti/sti_drm_encoder.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_ENCODER_H_ +#define _STI_DRM_ENCODER_H_ + +#include "sti_tvout.h" + +struct drm_encoder *sti_drm_encoder_create (struct drm_device *dev, +struct sti_tvout *tvout,unsigned int possible_crtcs, +enum sti_tvout_connector_type type); + +#endif drivers/gpu/drm/sti/sti_drm_plane.c new file +152
-0@@ -0,0 +1,195 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Authors: Benjamin Gaignard <[email protected]> +* Fabien Dessenne <[email protected]> +* for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ +#include "sti_drm_drv.h" +#include "sti_drm_plane.h" +#include "sti_compositor.h" +#include "sti_vtg_utils.h" + +enum sti_layer_desc sti_layer_default_zorder[] = { +STI_GDP_0 , +STI_VID_0 , +STI_GDP_1 , +STI_VID_1 , +STI_GDP_2 , +STI_GDP_3 , +}; + +/* (Background) < GDP0 < VID0 < GDP1 < VID1 < GDP2 < GDP3 < (ForeGround) */ + +static int +sti_drm_update_plane (struct drm_plane *plane,struct drm_crtc *crtc, +struct drm_framebuffer *fb,int crtc_x,int crtc_y, +unsigned int crtc_w,unsigned int crtc_h, +uint32_t src_x,uint32_t src_y, +uint32_t src_w,uint32_t src_h) +{ +struct sti_layer *layer =to_sti_layer (plane); +struct sti_mixer *mixer =to_sti_mixer (crtc); +int res; + +DRM_DEBUG_KMS ("CRTC:%d (%s) drm plane:%d (%s) drm fb:%d\n" , + crtc->base.id,sti_mixer_to_str (mixer), + plane->base.id,sti_layer_to_str (layer), fb->base.id); +DRM_DEBUG_KMS ("(%dx%d)@(%d,%d)\n" , crtc_w, crtc_h, crtc_x, crtc_y); + + res =sti_mixer_set_layer_depth (mixer, layer); +if (res) { +DRM_ERROR ("Can not set layer depth\n" ); +return res; + } + +/* src_x are in 16.16 format. */ + res =sti_layer_prepare (layer, fb, &crtc->mode, mixer->id, + crtc_x, crtc_y, crtc_w, crtc_h, + src_x >>16 , src_y >>16 , + src_w >>16 , src_h >>16 ); +if (res) { +DRM_ERROR ("Layer prepare failed\n" ); +return res; + } + + res =sti_layer_commit (layer); +if (res) { +DRM_ERROR ("Layer commit failed\n" ); +return res; + } + + res =sti_mixer_set_layer_status (mixer, layer, true); +if (res) { +DRM_ERROR ("Can not enable layer at mixer\n" ); +return res; + } + +return 0 ; +} + +static int sti_drm_disable_plane (struct drm_plane *plane) +{ +struct sti_layer *layer; +struct sti_mixer *mixer; +int lay_res, mix_res; + +if (!plane->crtc) { +DRM_DEBUG_DRIVER ("drm plane:%d not enabled\n" , plane->base.id); +return 0 ; + } + layer =to_sti_layer (plane); + mixer =to_sti_mixer (plane->crtc); + +DRM_DEBUG_DRIVER ("CRTC:%d (%s) drm plane:%d (%s)\n" , + plane->crtc->base.id,sti_mixer_to_str (mixer), + plane->base.id,sti_layer_to_str (layer)); + +/* Disable layer at mixer level */ + mix_res =sti_mixer_set_layer_status (mixer, layer, false); +if (mix_res) +DRM_ERROR ("Can not disable layer at mixer\n" ); + +/* Wait a while to be sure that a Vsync event is received */ +msleep (WAIT_NEXT_VSYNC_MS ); + +/* Then disable layer itself */ + lay_res =sti_layer_disable (layer); +if (lay_res) +DRM_ERROR ("Layer disable failed\n" ); + +if (lay_res || mix_res) +return 1 ; +else +return 0 ; +} + +static void sti_drm_plane_destroy (struct drm_plane *plane) +{ +DRM_DEBUG_DRIVER ("\n" ); + +sti_drm_disable_plane (plane); +drm_plane_cleanup (plane); +} + +static int sti_drm_plane_set_property (struct drm_plane *plane, +struct drm_property *property, +uint64_t val) +{ +struct drm_device *dev = plane->dev; +struct sti_drm_private *private = dev->dev_private; +struct sti_layer *layer =to_sti_layer (plane); + +DRM_DEBUG_DRIVER ("\n" ); + +if (property == private->plane_zorder_property) { + layer->zorder = val; +return 0 ; + } + +return -EINVAL ; +} + +static struct drm_plane_funcs sti_drm_plane_funcs = { + .update_plane = sti_drm_update_plane, + .disable_plane = sti_drm_disable_plane, + .destroy = sti_drm_plane_destroy, + .set_property = sti_drm_plane_set_property, +}; + +static void sti_drm_plane_attach_zorder_property (struct drm_plane *plane, +uint64_t default_val) +{ +struct drm_device *dev = plane->dev; +struct sti_drm_private *private = dev->dev_private; +struct drm_property *prop; +struct sti_layer *layer =to_sti_layer (plane); + +dev_dbg (dev->dev,"%s zorder:%llu\n" , __func__, default_val); + + prop = private->plane_zorder_property; +if (!prop) { + prop = drm_property_create_range(dev, 0, "zpos", 0,drivers/gpu/drm/sti/sti_drm_plane.c line 162
Quoted 10 lines
drivers/gpu/drm/sti/sti_drm_plane.c new file +10
-0+ GAM_MIXER_NB_DEPTH_LEVEL - 1); +if (!prop) +return ; + + private->plane_zorder_property = prop; + } + +drm_object_attach_property (&plane->base, prop, default_val); + layer->zorder = default_val; +}There's lots of ongoing discussions about standardizing properties a bit better. Especially about plane Z ordering and blending modes. I think it'd be good to hold off on this a bit and participate in the larger discussion about a spec for plane properties until things settle. Especially for a new driver.
I guess for now you could just hardcode Z order how you register the planes.
-DanielQuoted 71 lines
drivers/gpu/drm/sti/sti_drm_plane.c new file +33
-0+ +struct drm_plane *sti_drm_plane_init (struct drm_device *dev, +struct sti_layer *layer, +unsigned int possible_crtcs) +{ +int err, i; +uint64_t default_zorder =0 ; + +dev_dbg (dev->dev,"%s\n" , __func__); + + err =drm_plane_init (dev, &layer->plane, possible_crtcs, + &sti_drm_plane_funcs, +sti_layer_get_formats (layer), +sti_layer_get_nb_formats (layer), false); +if (err) { +DRM_ERROR ("Failed to initialize plane\n" ); +return NULL ; + } + +for (i =0 ; i <ARRAY_SIZE (sti_layer_default_zorder); i++) +if (sti_layer_default_zorder[i] == layer->desc) +break ; + + default_zorder = i; + +sti_drm_plane_attach_zorder_property (&layer->plane, default_zorder); + +DRM_DEBUG_DRIVER ("drm plane:%d mapped to %s with zorder:%llu\n" , + layer->plane.base.id, +sti_layer_to_str (layer), default_zorder); + +return &layer->plane; +}drivers/gpu/drm/sti/sti_drm_plane.h new file +16
-0@@ -0,0 +1,16 @@ +/* +* Copyright (C) STMicroelectronics SA 2013 +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#ifndef _STI_DRM_PLANE_H_ +#define _STI_DRM_PLANE_H_ + +#include <drm/drmP.h> +#include "sti_layer.h" + +struct drm_plane *sti_drm_plane_init (struct drm_device *dev, +struct sti_layer *layer,unsigned int possible_crtcs); + +#endif drivers/gpu/drm/sti/sti_vtg_utils.h +2
-1@@ -11,6 +11,8 @@#include <drm/drmP.h> +#define WAIT_NEXT_VSYNC_MS 50/*ms*/ +#define VTG_MAIN 0#define VTG_AUX 1 --1.9.0
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 11 lines
Benjamin Gaignard Graphic Working Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 18/19 drm: sti: add HQVDP driver
In reply to Benjamin GaignardHigh Quality Video Display Plug is a data path for doing high quality treatments (filtering, scaling) on video flow.
HQVDP IP is tunneled into compositor via VDP input.
--- drivers/gpu/drm/sti/Makefile | 1 + drivers/gpu/drm/sti/sti_drm_drv.c | 18 + drivers/gpu/drm/sti/sti_drm_drv.h | 4 + drivers/gpu/drm/sti/sti_hqvdp.c | 1089 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 ++ drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 ++++++++++++ drivers/gpu/drm/sti/sti_layer.c | 27 +- drivers/gpu/drm/sti/sti_layer.h | 3 + 8 files changed, 1564 insertions(+), 6 deletions(-) create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h
drivers/gpu/drm/sti/Makefile +1 -0
@@ -10,6 +10,7 @@ stidrm-y := sti_drm_drv.o \ sti_layer.o \ sti_gdp.o \ sti_vid.o \ + sti_hqvdp.o \ sti_tvout.o \ sti_hdmi.o \ sti_hdmi_tx3g0c55phy.o \
drivers/gpu/drm/sti/sti_drm_drv.c +18 -0
@@ -21,6 +21,7 @@#include "sti_drm_encoder.h" #include "sti_drm_connector.h" #include "sti_tvout.h" +#include "sti_hqvdp.h" #define DRIVER_NAME "sti"#define DRIVER_DESC "STMicroelectronics SoC DRM"
@@ -131,6 +132,7 @@ static struct drm_info_list sti_drm_dbg_list[] = { {"mixer", sti_mixer_dbg_show, 0}, {"hdmi", sti_tvout_hdmi_dbg_show, 0, NULL}, {"hda", sti_tvout_hda_dbg_show, 0, NULL}, + {"vdp", sti_hqvdp_dbg_show, 0, NULL}, };static int sti_drm_fps_get (void *data,u64 *val)
@@ -281,6 +283,16 @@ static int sti_drm_load(struct drm_device *dev, unsigned long flags)if (err)DRM_ERROR ("Failed to initialize TVOUT\n" ); +/* Load HQVDP firmware */ + drv =driver_find ("sti-hqvdp" , &platform_bus_type); +if (!drv) { +DRM_ERROR ("No HQVDP found\n" ); +return -ENOMEM ; + } + err =driver_for_each_device (drv,NULL , dev, sti_hqvdp_load_init); +if (err) +DRM_ERROR ("Failed to initialize HQVDP\n" ); +drm_helper_disable_unused_functions (dev);#ifdef CONFIG_DRM_STI_FBDEV sti_drm_device = dev;
@@ -410,6 +422,10 @@ static int __init sti_drm_init(void)if (ret <0 ) goto out_hda; + ret =platform_driver_register (&sti_hqvdp_driver); +if (ret <0 ) + goto out_hqvdp; + ret =platform_driver_register (&sti_drm_platform_driver);if (ret <0 ) goto out_drm;
@@ -427,6 +443,8 @@ out_drm_device:platform_driver_unregister (&sti_drm_platform_driver); out_drm:platform_driver_unregister (&sti_hda_driver); +out_hqvdp: +platform_driver_unregister (&sti_hqvdp_driver); out_hda:platform_driver_unregister (&sti_hdmi_driver); out_hdmi:
drivers/gpu/drm/sti/sti_drm_drv.h +4 -0
@@ -13,6 +13,7 @@#include "sti_compositor.h" #include "sti_tvout.h" +#include "sti_hqvdp.h" extern struct platform_driver sti_compositor_driver;extern struct platform_driver sti_vtac_tx_driver;
@@ -21,6 +22,7 @@ extern struct platform_driver sti_vtg_driver;extern struct platform_driver sti_tvout_driver;extern struct platform_driver sti_hdmi_driver;extern struct platform_driver sti_hda_driver; +extern struct platform_driver sti_hqvdp_driver;/* * STI drm private structure
@@ -28,12 +30,14 @@ extern struct platform_driver sti_hda_driver;* * @compo: compositor * @tvout: TV OUT +* @hqvdp: HQVDP * @pageflip_evt_list: list of pending page flip requests * @plane_zorder_property: z-order property for CRTC planes */ struct sti_drm_private {struct sti_compositor *compo;struct sti_tvout *tvout; +struct sti_hqvdp *hqvdp;struct list_head pageflip_evt_list;struct drm_property *plane_zorder_property; };
drivers/gpu/drm/sti/sti_hqvdp.c new file +1089 -0
1,089 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hqvdp.h new file +55 -0
55 lines not on this page · raw message
drivers/gpu/drm/sti/sti_hqvdp_lut.h new file +373 -0
373 lines not on this page · raw message
drivers/gpu/drm/sti/sti_layer.c +21 -6
@@ -100,6 +100,8 @@ struct sti_layer *sti_layer_create(struct device *dev, int desc, layer->vid =sti_vid_create (dev, baseaddr);if (!layer->vid) goto err; +/* The VDP descriptor is not created now, but will be added +* later upon HQVDP driver probe */ break ;default : goto err;
@@ -172,9 +174,10 @@ int sti_layer_prepare(struct sti_layer *layer, struct drm_framebuffer *fb, ret = layer->gdp->prepare (layer, !layer->enabled);break ;case STI_VID : -if (!layer->vid) +if ((!layer->vid) || (!layer->vdp)) goto err_no_prepare; - ret = layer->vid->prepare (layer, !layer->enabled); + ret = layer->vdp->prepare (layer, !layer->enabled); + ret |= layer->vid->prepare (layer, !layer->enabled);break ;default : goto err_no_prepare;
@@ -204,9 +207,10 @@ int sti_layer_commit(struct sti_layer *layer) ret = layer->gdp->commit (layer);break ;case STI_VID : -if (!layer->vid) +if ((!layer->vid) || (!layer->vdp)) goto err_no_commit; - ret = layer->vid->commit (layer); + ret = layer->vdp->commit (layer); + ret |= layer->vid->commit (layer);break ;default : goto err_no_commit;
@@ -240,9 +244,10 @@ int sti_layer_disable(struct sti_layer *layer) ret = layer->gdp->disable (layer);break ;case STI_VID : -if (!layer->vid) +if ((!layer->vid) || (!layer->vdp)) goto err_no_disable; - ret = layer->vid->disable (layer); + ret = layer->vdp->disable (layer); + ret |= layer->vid->disable (layer);break ;default : goto err_no_disable;
@@ -272,6 +277,11 @@ const uint32_t *sti_layer_get_formats(struct sti_layer *layer)if (layer->gdp) get_formats = layer->gdp->get_formats;break ; +case STI_VID : +/* The single input of [VDP+VID] is VDP */ +if (layer->vdp) + get_formats = layer->vdp->get_formats; +break ;default :break ; }
@@ -296,6 +306,11 @@ int sti_layer_get_nb_formats(struct sti_layer *layer)if (layer->gdp) get_nb_formats = layer->gdp->get_nb_formats;break ; +case STI_VID : +/* The single input of [VDP+VID] is VDP */ +if (layer->vdp) + get_nb_formats = layer->vdp->get_nb_formats; +break ;default :break ; }
drivers/gpu/drm/sti/sti_layer.h +3 -0
@@ -12,6 +12,7 @@#include <drm/drmP.h> #include "sti_gdp.h" #include "sti_vid.h" +#include "sti_hqvdp.h" #define to_sti_layer (x) container_of(x, struct sti_layer, plane)
@@ -72,6 +73,7 @@ struct sti_fps_info {* @fps_info: frame per second info * @gdp: related GDP (if the layer is a GDP) * @vid: related VID (if the layer is a VID/VDP) +* @vdp: related VDP (if the layer is a VID/VDP) */ struct sti_layer {struct drm_plane plane;
@@ -92,6 +94,7 @@ struct sti_layer {struct sti_fps_info fps_info;struct sti_gdp *gdp;struct sti_vid *vid; +struct sti_vdp *vdp; }; struct sti_layer *sti_layer_create(struct device *dev, int desc,
Signature · 1 line
1.9.0
PATCH 19/19 drm: sti: rename mixer registers to be main/aux independent
In reply to Benjamin GaignardFrom: Vincent Abriou <[email protected]>
--- drivers/gpu/drm/sti/sti_mixer.c | 70 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
drivers/gpu/drm/sti/sti_mixer.c +35 -35
@@ -18,16 +18,16 @@ static const u32 MixerColorSpaceMatIdentity[] = { };/* regs offset */ -#define GAM_MIXER_MAIN_CTL 0x00 -#define GAM_MIXER_MAIN_BKC 0x04 -#define GAM_MIXER_MAIN_BCO 0x0C -#define GAM_MIXER_MAIN_BCS 0x10 -#define GAM_MIXER_MAIN_AVO 0x28 -#define GAM_MIXER_MAIN_AVS 0x2C -#define GAM_MIXER_MAIN_CRB 0x34 -#define GAM_MIXER_MAIN_ACT 0x38 -#define GAM_MIXER_MAIN_MBP 0x3C -#define GAM_MIXER_MAIN_MX0 0x80 +#define GAM_MIXER_CTL 0x00 +#define GAM_MIXER_BKC 0x04 +#define GAM_MIXER_BCO 0x0C +#define GAM_MIXER_BCS 0x10 +#define GAM_MIXER_AVO 0x28 +#define GAM_MIXER_AVS 0x2C +#define GAM_MIXER_CRB 0x34 +#define GAM_MIXER_ACT 0x38 +#define GAM_MIXER_MBP 0x3C +#define GAM_MIXER_MX0 0x80/* id for depth of CRB reg */ #define GAM_DEPTH_VID0_ID 1
@@ -82,7 +82,7 @@ static inline void sti_mixer_reg_writemask(struct sti_mixer *mixer,void sti_mixer_set_background_status (struct sti_mixer *mixer,bool enable) {sti_mixer_reg_writemask (mixer, -GAM_MIXER_MAIN_CTL , enable,GAM_CTL_BACK_MASK ); +GAM_MIXER_CTL , enable,GAM_CTL_BACK_MASK ); } static void sti_mixer_set_background_color(struct sti_mixer *mixer,
@@ -90,7 +90,7 @@ static void sti_mixer_set_background_color(struct sti_mixer *mixer, {u32 val = (red <<16 ) | (green <<8 ) | blue; -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_BKC , val); +sti_mixer_reg_write (mixer,GAM_MIXER_BKC , val); } static void sti_mixer_set_background_area(struct sti_mixer *mixer,
@@ -103,8 +103,8 @@ static void sti_mixer_set_background_area(struct sti_mixer *mixer, xdo =sti_vtg_get_pixel_number (*mode,0 ); xds =sti_vtg_get_pixel_number (*mode, mode->hdisplay -1 ); -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_BCO , ydo <<16 | xdo); -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_BCS , yds <<16 | xds); +sti_mixer_reg_write (mixer,GAM_MIXER_BCO , ydo <<16 | xdo); +sti_mixer_reg_write (mixer,GAM_MIXER_BCS , yds <<16 | xds); }int sti_mixer_set_layer_depth (struct sti_mixer *mixer,struct sti_layer *layer)
@@ -143,12 +143,12 @@ int sti_mixer_set_layer_depth(struct sti_mixer *mixer, struct sti_layer *layer)DRM_DEBUG_DRIVER ("%s %s depth=%d\n" ,sti_mixer_to_str (mixer),sti_layer_to_str (layer), depth); -dev_dbg (mixer->dev,"GAM_MIXER_MAIN_CRB val 0x%x mask 0x%x\n" , +dev_dbg (mixer->dev,"GAM_MIXER_CRB val 0x%x mask 0x%x\n" , layer_id, mask); -sti_mixer_reg_writemask (mixer,GAM_MIXER_MAIN_CRB , layer_id, mask); +sti_mixer_reg_writemask (mixer,GAM_MIXER_CRB , layer_id, mask); -dev_dbg (mixer->dev,"Read GAM_MIXER_MAIN_CRB 0x%x\n" , -sti_mixer_reg_read (mixer,GAM_MIXER_MAIN_CRB )); +dev_dbg (mixer->dev,"Read GAM_MIXER_CRB 0x%x\n" , +sti_mixer_reg_read (mixer,GAM_MIXER_CRB ));return 0 ; }
@@ -164,8 +164,8 @@ int sti_mixer_active_video_area(struct sti_mixer *mixer,DRM_DEBUG_DRIVER ("%s active video area xdo:%d ydo:%d xds:%d yds:%d\n" ,sti_mixer_to_str (mixer), xdo, ydo, xds, yds); -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_AVO , ydo <<16 | xdo); -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_AVS , yds <<16 | xds); +sti_mixer_reg_write (mixer,GAM_MIXER_AVO , ydo <<16 | xdo); +sti_mixer_reg_write (mixer,GAM_MIXER_AVS , yds <<16 | xds);sti_mixer_set_background_color (mixer,0xFF ,0 ,0 );
@@ -210,7 +210,7 @@ int sti_mixer_set_layer_status(struct sti_mixer *mixer,return -1 ; } val = status ? mask :0 ; -sti_mixer_reg_writemask (mixer,GAM_MIXER_MAIN_CTL , val, mask); +sti_mixer_reg_writemask (mixer,GAM_MIXER_CTL , val, mask);return 0 ; }
@@ -219,7 +219,7 @@ void sti_mixer_set_matrix(struct sti_mixer *mixer)int i;for (i =0 ; i <ARRAY_SIZE (MixerColorSpaceMatIdentity); i++) -sti_mixer_reg_write (mixer,GAM_MIXER_MAIN_MX0 + (i *4 ), +sti_mixer_reg_write (mixer,GAM_MIXER_MX0 + (i *4 ), MixerColorSpaceMatIdentity[i]); }
@@ -359,23 +359,23 @@ int sti_mixer_dbg_show(struct seq_file *m, void *arg)struct sti_mixer *mixer = compo->mixer[i];seq_printf (m,"\n%s" ,sti_mixer_to_str (mixer)); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_CTL ); +MIXER_DBG_DUMP (GAM_MIXER_CTL );sti_mixer_dbg_ctl (m,sti_mixer_reg_read (mixer, -GAM_MIXER_MAIN_CTL )); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_BKC ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_BCO ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_BCS ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_AVO ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_AVS ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_CRB ); +GAM_MIXER_CTL )); +MIXER_DBG_DUMP (GAM_MIXER_BKC ); +MIXER_DBG_DUMP (GAM_MIXER_BCO ); +MIXER_DBG_DUMP (GAM_MIXER_BCS ); +MIXER_DBG_DUMP (GAM_MIXER_AVO ); +MIXER_DBG_DUMP (GAM_MIXER_AVS ); +MIXER_DBG_DUMP (GAM_MIXER_CRB );sti_mixer_dbg_crb (m,sti_mixer_reg_read (mixer, -GAM_MIXER_MAIN_CRB )); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_ACT ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_MBP ); -MIXER_DBG_DUMP (GAM_MIXER_MAIN_MX0 ); -sti_mixer_dbg_mxn (m, mixer->regs +GAM_MIXER_MAIN_MX0 ); +GAM_MIXER_CRB )); +MIXER_DBG_DUMP (GAM_MIXER_ACT ); +MIXER_DBG_DUMP (GAM_MIXER_MBP ); +MIXER_DBG_DUMP (GAM_MIXER_MX0 ); +sti_mixer_dbg_mxn (m, mixer->regs +GAM_MIXER_MX0 );seq_puts (m,"\n" ); crtc = &mixer->drm_crtc;
Signature · 1 line
1.9.0
Quoted 2 lines · Benjamin Gaignard
This series of patches add the support of DRM/KMS drivers for STMicroelectronics chipsets stih416 and stih407.
*finally* \o/
one small request.. got a git branch somewhere? This patchset is big enough that it would be convenient for reviewing to be able to git-fetch..
BR,
-R
Quoted 197 lines
Hardware is split in two main blocks: Compositor and TVout. Each of them includes specific hardware IPs and the display timing are controlled by a specific Video Timing Generator hardware IP (VTG).
Compositor is made of the follow hardware IPs:
- GDP (Generic Display Pipeline) which is an entry point for graphic (RGB) buffers
- VDP (Video Diplay Pipeline) which is an entry point for video (YUV) buffers
- HQVDP (High Quality Video Display Processor) that supports scaling, deinterlacing and some miscellaneous image quality improvements. It fetches the Video decoded buffers from memory, processes them and pushes them to the Compositor through a HW dedicated bus.
- Mixer is responsible of mixing all the entries depending of their respective z-order and layoutTVout is divided in 3 parts:
- HDMI to generate HDMI signals, depending of chipset version HDMI phy can change.
- HDA to generate signals for HD analog TV
- VIP to control/switch data path coming from CompositorOn stih416 compositor and Tvout are on different dies so a Video Trafic Advance inter-die Communication mechanism (VTAC) is needed.
+---------------------------------------------+ +----------------------------------------+ | +-------------------------------+ +----+ | | +----+ +--------------------------+ | | | | | | | | | | | +---------+ +----+ | | | | +----+ +------+ | | | | | | | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | | | | | | | +----+ | | | | +----+ |Mixer |--|-->| | | | | |---|->| switcher| | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | |---->|HDA | | | | | +------+ | |VTAC|========>|VTAC| | +---------+ +----+ | | | | | | | | | | | | | | | | Compositor | | | | | | | | TVout | | | +-------------------------------+ | | | | | | +--------------------------+ | | ^ | | | | | | ^ | | | | | | | | | | | | +--------------+ | | | | | | +-------------+ | | | VTG (master) |----->| | | | | |----->| VTG (slave) | | | +--------------+ +----+ | | +----+ +-------------+ | |Digital die | | Analog Die| +---------------------------------------------+ +----------------------------------------+On stih407 Compositor and Tvout are on the same die
+-----------------------------------------------------------------+ | +-------------------------------+ +--------------------------+ | | | | | +---------+ +----+ | | | | +----+ +------+ | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | +----+ | | | | +----+ |Mixer |--|--|->| switcher| | | | | +----+ +-----+ | | | | | | +----+ | | | | |VDP +-->+HQVDP+--->| | | | | |---->|HDA | | | | | +----+ +-----+ +------+ | | +---------+ +----+ | | | | | | | | | | Compositor | | TVout | | | +-------------------------------+ +--------------------------+ | | ^ ^ | | | | | | +--------------+ | | | VTG | | | +--------------+ | |Digital die | +-----------------------------------------------------------------+In addition of the drivers for the IPs listed before a thin I2C driver (hdmiddc) is used by HDMI driver to retrieve EDID for monitor.
To unify interfaces of GDP and VDP we create a "layer" interface called by compositor to control both GPD and VDP.
Hardware have memory contraints (alignment, contiguous) so we use CMA drm helpers functions to allocate frame buffer.
File naming convention is:
- sti_* for IPs drivers
- sti_drm_* for drm functions implementation.Benjamin Gaignard (18):
drm: sti: add bindings for DRM driver
drm: sti: add VTG driver
drm: sti: add VTAC drivers
drm: sti: add HDMI driver
drm: sti: add I2C client driver for HDMI
drm: sti: add HDA driver
drm: sti: add TVOut driver
drm: sti: add sti layer interface definition
drm: sti: add GDP layer
drm: sti: add VID layer
drm: sti: add Mixer
drm: sti: add Compositor
drm: sti: add debug to GDP
drm: sti: add debug to VID
drm: sti: add debug to TVout
drm: sti: add debug to mixer
drm: sti: Add DRM driver itself
drm: sti: add HQVDP driverVincent Abriou (1):
drm: sti: rename mixer registers to be main/aux independent.../devicetree/bindings/gpu/st,stih4xx.txt | 177 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 26 + drivers/gpu/drm/sti/Makefile | 23 + drivers/gpu/drm/sti/sti_compositor.c | 189 ++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++ drivers/gpu/drm/sti/sti_ddc.c | 56 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 + drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 + drivers/gpu/drm/sti/sti_drm_drv.c | 484 +++++++++ drivers/gpu/drm/sti/sti_drm_drv.h | 48 + drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 + drivers/gpu/drm/sti/sti_drm_plane.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 + drivers/gpu/drm/sti/sti_gdp.c | 726 +++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 75 ++ drivers/gpu/drm/sti/sti_hda.c | 826 +++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 1045 +++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 198 ++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 ++++ drivers/gpu/drm/sti/sti_hqvdp.c | 1089 ++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 + drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 +++++++ drivers/gpu/drm/sti/sti_layer.c | 324 ++++++ drivers/gpu/drm/sti/sti_layer.h | 116 +++ drivers/gpu/drm/sti/sti_mixer.c | 405 ++++++++ drivers/gpu/drm/sti/sti_mixer.h | 54 + drivers/gpu/drm/sti/sti_tvout.c | 863 ++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 ++ drivers/gpu/drm/sti/sti_vid.c | 259 +++++ drivers/gpu/drm/sti/sti_vid.h | 34 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 +++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 + drivers/gpu/drm/sti/sti_vtg.c | 438 ++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 + drivers/gpu/drm/sti/sti_vtg_utils.c | 99 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 29 + 44 files changed, 10303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_ddc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h create mode 100644 drivers/gpu/drm/sti/sti_hda.c create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c create mode 100644 drivers/gpu/drm/sti/sti_layer.h create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h--
1.9.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
You can found the patches here:
git://git.linaro.org/people/benjamin.gaignard/kernel.git
on branch: drm_kms_for_next
Regards,
Benjamin
2014-04-08 14:27 GMT+02:00 Rob Clark <[email protected]>:
Quoted 211 lines
Quoted 2 lines · Benjamin Gaignard
This series of patches add the support of DRM/KMS drivers for STMicroelectronics chipsets stih416 and stih407.
*finally* \o/
one small request.. got a git branch somewhere? This patchset is big enough that it would be convenient for reviewing to be able to git-fetch..
BR,
-RQuoted 197 lines
Hardware is split in two main blocks: Compositor and TVout. Each of them includes specific hardware IPs and the display timing are controlled by a specific Video Timing Generator hardware IP (VTG).
Compositor is made of the follow hardware IPs:
- GDP (Generic Display Pipeline) which is an entry point for graphic (RGB) buffers
- VDP (Video Diplay Pipeline) which is an entry point for video (YUV) buffers
- HQVDP (High Quality Video Display Processor) that supports scaling, deinterlacing and some miscellaneous image quality improvements. It fetches the Video decoded buffers from memory, processes them and pushes them to the Compositor through a HW dedicated bus.
- Mixer is responsible of mixing all the entries depending of their respective z-order and layoutTVout is divided in 3 parts:
- HDMI to generate HDMI signals, depending of chipset version HDMI phy can change.
- HDA to generate signals for HD analog TV
- VIP to control/switch data path coming from CompositorOn stih416 compositor and Tvout are on different dies so a Video Trafic Advance inter-die Communication mechanism (VTAC) is needed.
+---------------------------------------------+ +----------------------------------------+ | +-------------------------------+ +----+ | | +----+ +--------------------------+ | | | | | | | | | | | +---------+ +----+ | | | | +----+ +------+ | | | | | | | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | | | | | | | +----+ | | | | +----+ |Mixer |--|-->| | | | | |---|->| switcher| | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | |---->|HDA | | | | | +------+ | |VTAC|========>|VTAC| | +---------+ +----+ | | | | | | | | | | | | | | | | Compositor | | | | | | | | TVout | | | +-------------------------------+ | | | | | | +--------------------------+ | | ^ | | | | | | ^ | | | | | | | | | | | | +--------------+ | | | | | | +-------------+ | | | VTG (master) |----->| | | | | |----->| VTG (slave) | | | +--------------+ +----+ | | +----+ +-------------+ | |Digital die | | Analog Die| +---------------------------------------------+ +----------------------------------------+On stih407 Compositor and Tvout are on the same die
+-----------------------------------------------------------------+ | +-------------------------------+ +--------------------------+ | | | | | +---------+ +----+ | | | | +----+ +------+ | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | +----+ | | | | +----+ |Mixer |--|--|->| switcher| | | | | +----+ +-----+ | | | | | | +----+ | | | | |VDP +-->+HQVDP+--->| | | | | |---->|HDA | | | | | +----+ +-----+ +------+ | | +---------+ +----+ | | | | | | | | | | Compositor | | TVout | | | +-------------------------------+ +--------------------------+ | | ^ ^ | | | | | | +--------------+ | | | VTG | | | +--------------+ | |Digital die | +-----------------------------------------------------------------+In addition of the drivers for the IPs listed before a thin I2C driver (hdmiddc) is used by HDMI driver to retrieve EDID for monitor.
To unify interfaces of GDP and VDP we create a "layer" interface called by compositor to control both GPD and VDP.
Hardware have memory contraints (alignment, contiguous) so we use CMA drm helpers functions to allocate frame buffer.
File naming convention is:
- sti_* for IPs drivers
- sti_drm_* for drm functions implementation.Benjamin Gaignard (18):
drm: sti: add bindings for DRM driver
drm: sti: add VTG driver
drm: sti: add VTAC drivers
drm: sti: add HDMI driver
drm: sti: add I2C client driver for HDMI
drm: sti: add HDA driver
drm: sti: add TVOut driver
drm: sti: add sti layer interface definition
drm: sti: add GDP layer
drm: sti: add VID layer
drm: sti: add Mixer
drm: sti: add Compositor
drm: sti: add debug to GDP
drm: sti: add debug to VID
drm: sti: add debug to TVout
drm: sti: add debug to mixer
drm: sti: Add DRM driver itself
drm: sti: add HQVDP driverVincent Abriou (1):
drm: sti: rename mixer registers to be main/aux independent.../devicetree/bindings/gpu/st,stih4xx.txt | 177 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 26 + drivers/gpu/drm/sti/Makefile | 23 + drivers/gpu/drm/sti/sti_compositor.c | 189 ++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++ drivers/gpu/drm/sti/sti_ddc.c | 56 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 + drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 + drivers/gpu/drm/sti/sti_drm_drv.c | 484 +++++++++ drivers/gpu/drm/sti/sti_drm_drv.h | 48 + drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 + drivers/gpu/drm/sti/sti_drm_plane.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 + drivers/gpu/drm/sti/sti_gdp.c | 726 +++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 75 ++ drivers/gpu/drm/sti/sti_hda.c | 826 +++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 1045 +++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 198 ++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 ++++ drivers/gpu/drm/sti/sti_hqvdp.c | 1089 ++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 + drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 +++++++ drivers/gpu/drm/sti/sti_layer.c | 324 ++++++ drivers/gpu/drm/sti/sti_layer.h | 116 +++ drivers/gpu/drm/sti/sti_mixer.c | 405 ++++++++ drivers/gpu/drm/sti/sti_mixer.h | 54 + drivers/gpu/drm/sti/sti_tvout.c | 863 ++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 ++ drivers/gpu/drm/sti/sti_vid.c | 259 +++++ drivers/gpu/drm/sti/sti_vid.h | 34 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 +++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 + drivers/gpu/drm/sti/sti_vtg.c | 438 ++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 + drivers/gpu/drm/sti/sti_vtg_utils.c | 99 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 29 + 44 files changed, 10303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_ddc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h create mode 100644 drivers/gpu/drm/sti/sti_hda.c create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c create mode 100644 drivers/gpu/drm/sti/sti_layer.h create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h--
1.9.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 11 lines
Benjamin Gaignard Graphic Working Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dear maintainers/reviewers, just an UP to remind you that this patcheset is waiting for your feedback.
Patches 1-12 and 18-19 mainly concern drivers for the various hardware IP. Patches 13-16 add debug to those drivers.
Patches 17 is the DRM driver.
I know that review 10K lines isn't easy, takes times and is not fun, but without your comments/remarks it will be difficult for me to deliver you something with the expected level of quality.
Regards,
Benjamin
2014-04-08 16:14 GMT+02:00 Benjamin Gaignard <[email protected]>:
Quoted 232 lines
You can found the patches here:
git://git.linaro.org/people/benjamin.gaignard/kernel.git
on branch:drm_kms_for_nextRegards,
Benjamin2014-04-08 14:27 GMT+02:00 Rob Clark <[email protected]>:
Quoted 5 lines
Quoted 2 lines · Benjamin Gaignard
This series of patches add the support of DRM/KMS drivers for STMicroelectronics chipsets stih416 and stih407.
Quoted 206 lines
*finally* \o/
one small request.. got a git branch somewhere? This patchset is big enough that it would be convenient for reviewing to be able to git-fetch..
BR,
-RQuoted 197 lines
Hardware is split in two main blocks: Compositor and TVout. Each of them includes specific hardware IPs and the display timing are controlled by a specific Video Timing Generator hardware IP (VTG).
Compositor is made of the follow hardware IPs:
- GDP (Generic Display Pipeline) which is an entry point for graphic (RGB) buffers
- VDP (Video Diplay Pipeline) which is an entry point for video (YUV) buffers
- HQVDP (High Quality Video Display Processor) that supports scaling, deinterlacing and some miscellaneous image quality improvements. It fetches the Video decoded buffers from memory, processes them and pushes them to the Compositor through a HW dedicated bus.
- Mixer is responsible of mixing all the entries depending of their respective z-order and layoutTVout is divided in 3 parts:
- HDMI to generate HDMI signals, depending of chipset version HDMI phy can change.
- HDA to generate signals for HD analog TV
- VIP to control/switch data path coming from CompositorOn stih416 compositor and Tvout are on different dies so a Video Trafic Advance inter-die Communication mechanism (VTAC) is needed.
+---------------------------------------------+ +----------------------------------------+ | +-------------------------------+ +----+ | | +----+ +--------------------------+ | | | | | | | | | | | +---------+ +----+ | | | | +----+ +------+ | | | | | | | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | | | | | | | +----+ | | | | +----+ |Mixer |--|-->| | | | | |---|->| switcher| | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | |---->|HDA | | | | | +------+ | |VTAC|========>|VTAC| | +---------+ +----+ | | | | | | | | | | | | | | | | Compositor | | | | | | | | TVout | | | +-------------------------------+ | | | | | | +--------------------------+ | | ^ | | | | | | ^ | | | | | | | | | | | | +--------------+ | | | | | | +-------------+ | | | VTG (master) |----->| | | | | |----->| VTG (slave) | | | +--------------+ +----+ | | +----+ +-------------+ | |Digital die | | Analog Die| +---------------------------------------------+ +----------------------------------------+On stih407 Compositor and Tvout are on the same die
+-----------------------------------------------------------------+ | +-------------------------------+ +--------------------------+ | | | | | +---------+ +----+ | | | | +----+ +------+ | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | +----+ | | | | +----+ |Mixer |--|--|->| switcher| | | | | +----+ +-----+ | | | | | | +----+ | | | | |VDP +-->+HQVDP+--->| | | | | |---->|HDA | | | | | +----+ +-----+ +------+ | | +---------+ +----+ | | | | | | | | | | Compositor | | TVout | | | +-------------------------------+ +--------------------------+ | | ^ ^ | | | | | | +--------------+ | | | VTG | | | +--------------+ | |Digital die | +-----------------------------------------------------------------+In addition of the drivers for the IPs listed before a thin I2C driver (hdmiddc) is used by HDMI driver to retrieve EDID for monitor.
To unify interfaces of GDP and VDP we create a "layer" interface called by compositor to control both GPD and VDP.
Hardware have memory contraints (alignment, contiguous) so we use CMA drm helpers functions to allocate frame buffer.
File naming convention is:
- sti_* for IPs drivers
- sti_drm_* for drm functions implementation.Benjamin Gaignard (18):
drm: sti: add bindings for DRM driver
drm: sti: add VTG driver
drm: sti: add VTAC drivers
drm: sti: add HDMI driver
drm: sti: add I2C client driver for HDMI
drm: sti: add HDA driver
drm: sti: add TVOut driver
drm: sti: add sti layer interface definition
drm: sti: add GDP layer
drm: sti: add VID layer
drm: sti: add Mixer
drm: sti: add Compositor
drm: sti: add debug to GDP
drm: sti: add debug to VID
drm: sti: add debug to TVout
drm: sti: add debug to mixer
drm: sti: Add DRM driver itself
drm: sti: add HQVDP driverVincent Abriou (1):
drm: sti: rename mixer registers to be main/aux independent.../devicetree/bindings/gpu/st,stih4xx.txt | 177 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 26 + drivers/gpu/drm/sti/Makefile | 23 + drivers/gpu/drm/sti/sti_compositor.c | 189 ++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++ drivers/gpu/drm/sti/sti_ddc.c | 56 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 + drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 + drivers/gpu/drm/sti/sti_drm_drv.c | 484 +++++++++ drivers/gpu/drm/sti/sti_drm_drv.h | 48 + drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 + drivers/gpu/drm/sti/sti_drm_plane.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 + drivers/gpu/drm/sti/sti_gdp.c | 726 +++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 75 ++ drivers/gpu/drm/sti/sti_hda.c | 826 +++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 1045 +++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 198 ++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 ++++ drivers/gpu/drm/sti/sti_hqvdp.c | 1089 ++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 + drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 +++++++ drivers/gpu/drm/sti/sti_layer.c | 324 ++++++ drivers/gpu/drm/sti/sti_layer.h | 116 +++ drivers/gpu/drm/sti/sti_mixer.c | 405 ++++++++ drivers/gpu/drm/sti/sti_mixer.h | 54 + drivers/gpu/drm/sti/sti_tvout.c | 863 ++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 ++ drivers/gpu/drm/sti/sti_vid.c | 259 +++++ drivers/gpu/drm/sti/sti_vid.h | 34 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 +++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 + drivers/gpu/drm/sti/sti_vtg.c | 438 ++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 + drivers/gpu/drm/sti/sti_vtg_utils.c | 99 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 29 + 44 files changed, 10303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_ddc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h create mode 100644 drivers/gpu/drm/sti/sti_hda.c create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c create mode 100644 drivers/gpu/drm/sti/sti_layer.h create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h--
1.9.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel--
Benjamin GaignardGraphic Working Group
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Signature · 11 lines
Benjamin Gaignard Graphic Working Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
just a quick note, I think you are missing some EXPORT_SYMBOL()'s:
ERROR: "sti_vtg_setconfig" [drivers/gpu/drm/sti/stidrm.ko] undefined!
ERROR: "sti_vtg_get_pixel_number" [drivers/gpu/drm/sti/stidrm.ko] undefined!
ERROR: "sti_vtg_register_client" [drivers/gpu/drm/sti/stidrm.ko] undefined!
ERROR: "sti_vtg_get_line_number" [drivers/gpu/drm/sti/stidrm.ko] undefined!
ERROR: "sti_vtg_unregister_client" [drivers/gpu/drm/sti/stidrm.ko] undefined!
ERROR: "vtg_unregister_client" [drivers/gpu/drm/sti/sti_vtg_utils.ko] undefined!
ERROR: "vtg_register_client" [drivers/gpu/drm/sti/sti_vtg_utils.ko] undefined!
ERROR: "vtg_set_config" [drivers/gpu/drm/sti/sti_vtg_utils.ko] undefined!
ERROR: "vtg_main" [drivers/gpu/drm/sti/sti_vtg.ko] undefined!
ERROR: "vtg_aux" [drivers/gpu/drm/sti/sti_vtg.ko] undefined!
BR,
-R
Quoted 250 lines · Benjamin Gaignard
Dear maintainers/reviewers, just an UP to remind you that this patcheset is waiting for your feedback.
Patches 1-12 and 18-19 mainly concern drivers for the various hardware IP. Patches 13-16 add debug to those drivers.
Patches 17 is the DRM driver.I know that review 10K lines isn't easy, takes times and is not fun, but without your comments/remarks it will be difficult for me to deliver you something with the expected level of quality.
Regards,
Benjamin2014-04-08 16:14 GMT+02:00 Benjamin Gaignard <[email protected]>:
Quoted 224 lines
You can found the patches here:
git://git.linaro.org/people/benjamin.gaignard/kernel.git
on branch:drm_kms_for_nextRegards,
Benjamin2014-04-08 14:27 GMT+02:00 Rob Clark <[email protected]>:
Quoted 5 lines
Quoted 2 lines · Benjamin Gaignard
This series of patches add the support of DRM/KMS drivers for STMicroelectronics chipsets stih416 and stih407.
Quoted 206 lines
*finally* \o/
one small request.. got a git branch somewhere? This patchset is big enough that it would be convenient for reviewing to be able to git-fetch..
BR,
-RQuoted 197 lines
Hardware is split in two main blocks: Compositor and TVout. Each of them includes specific hardware IPs and the display timing are controlled by a specific Video Timing Generator hardware IP (VTG).
Compositor is made of the follow hardware IPs:
- GDP (Generic Display Pipeline) which is an entry point for graphic (RGB) buffers
- VDP (Video Diplay Pipeline) which is an entry point for video (YUV) buffers
- HQVDP (High Quality Video Display Processor) that supports scaling, deinterlacing and some miscellaneous image quality improvements. It fetches the Video decoded buffers from memory, processes them and pushes them to the Compositor through a HW dedicated bus.
- Mixer is responsible of mixing all the entries depending of their respective z-order and layoutTVout is divided in 3 parts:
- HDMI to generate HDMI signals, depending of chipset version HDMI phy can change.
- HDA to generate signals for HD analog TV
- VIP to control/switch data path coming from CompositorOn stih416 compositor and Tvout are on different dies so a Video Trafic Advance inter-die Communication mechanism (VTAC) is needed.
+---------------------------------------------+ +----------------------------------------+ | +-------------------------------+ +----+ | | +----+ +--------------------------+ | | | | | | | | | | | +---------+ +----+ | | | | +----+ +------+ | | | | | | | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | | | | | | | +----+ | | | | +----+ |Mixer |--|-->| | | | | |---|->| switcher| | | | | | | | | | | | | | | | | +----+ | | | | | | | | | | | | | | | |---->|HDA | | | | | +------+ | |VTAC|========>|VTAC| | +---------+ +----+ | | | | | | | | | | | | | | | | Compositor | | | | | | | | TVout | | | +-------------------------------+ | | | | | | +--------------------------+ | | ^ | | | | | | ^ | | | | | | | | | | | | +--------------+ | | | | | | +-------------+ | | | VTG (master) |----->| | | | | |----->| VTG (slave) | | | +--------------+ +----+ | | +----+ +-------------+ | |Digital die | | Analog Die| +---------------------------------------------+ +----------------------------------------+On stih407 Compositor and Tvout are on the same die
+-----------------------------------------------------------------+ | +-------------------------------+ +--------------------------+ | | | | | +---------+ +----+ | | | | +----+ +------+ | | | VIP |---->|HDMI| | | | | |GPD +------------->| | | | | | +----+ | | | | +----+ |Mixer |--|--|->| switcher| | | | | +----+ +-----+ | | | | | | +----+ | | | | |VDP +-->+HQVDP+--->| | | | | |---->|HDA | | | | | +----+ +-----+ +------+ | | +---------+ +----+ | | | | | | | | | | Compositor | | TVout | | | +-------------------------------+ +--------------------------+ | | ^ ^ | | | | | | +--------------+ | | | VTG | | | +--------------+ | |Digital die | +-----------------------------------------------------------------+In addition of the drivers for the IPs listed before a thin I2C driver (hdmiddc) is used by HDMI driver to retrieve EDID for monitor.
To unify interfaces of GDP and VDP we create a "layer" interface called by compositor to control both GPD and VDP.
Hardware have memory contraints (alignment, contiguous) so we use CMA drm helpers functions to allocate frame buffer.
File naming convention is:
- sti_* for IPs drivers
- sti_drm_* for drm functions implementation.Benjamin Gaignard (18):
drm: sti: add bindings for DRM driver
drm: sti: add VTG driver
drm: sti: add VTAC drivers
drm: sti: add HDMI driver
drm: sti: add I2C client driver for HDMI
drm: sti: add HDA driver
drm: sti: add TVOut driver
drm: sti: add sti layer interface definition
drm: sti: add GDP layer
drm: sti: add VID layer
drm: sti: add Mixer
drm: sti: add Compositor
drm: sti: add debug to GDP
drm: sti: add debug to VID
drm: sti: add debug to TVout
drm: sti: add debug to mixer
drm: sti: Add DRM driver itself
drm: sti: add HQVDP driverVincent Abriou (1):
drm: sti: rename mixer registers to be main/aux independent.../devicetree/bindings/gpu/st,stih4xx.txt | 177 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sti/Kconfig | 26 + drivers/gpu/drm/sti/Makefile | 23 + drivers/gpu/drm/sti/sti_compositor.c | 189 ++++ drivers/gpu/drm/sti/sti_compositor.h | 84 ++ drivers/gpu/drm/sti/sti_ddc.c | 56 + drivers/gpu/drm/sti/sti_drm_connector.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_connector.h | 16 + drivers/gpu/drm/sti/sti_drm_crtc.c | 440 ++++++++ drivers/gpu/drm/sti/sti_drm_crtc.h | 21 + drivers/gpu/drm/sti/sti_drm_drv.c | 484 +++++++++ drivers/gpu/drm/sti/sti_drm_drv.h | 48 + drivers/gpu/drm/sti/sti_drm_encoder.c | 201 ++++ drivers/gpu/drm/sti/sti_drm_encoder.h | 16 + drivers/gpu/drm/sti/sti_drm_plane.c | 195 ++++ drivers/gpu/drm/sti/sti_drm_plane.h | 16 + drivers/gpu/drm/sti/sti_gdp.c | 726 +++++++++++++ drivers/gpu/drm/sti/sti_gdp.h | 75 ++ drivers/gpu/drm/sti/sti_hda.c | 826 +++++++++++++++ drivers/gpu/drm/sti/sti_hda.h | 14 + drivers/gpu/drm/sti/sti_hdmi.c | 1045 +++++++++++++++++++ drivers/gpu/drm/sti/sti_hdmi.h | 198 ++++ drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c | 398 +++++++ drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c | 224 ++++ drivers/gpu/drm/sti/sti_hqvdp.c | 1089 ++++++++++++++++++++ drivers/gpu/drm/sti/sti_hqvdp.h | 55 + drivers/gpu/drm/sti/sti_hqvdp_lut.h | 373 +++++++ drivers/gpu/drm/sti/sti_layer.c | 324 ++++++ drivers/gpu/drm/sti/sti_layer.h | 116 +++ drivers/gpu/drm/sti/sti_mixer.c | 405 ++++++++ drivers/gpu/drm/sti/sti_mixer.h | 54 + drivers/gpu/drm/sti/sti_tvout.c | 863 ++++++++++++++++ drivers/gpu/drm/sti/sti_tvout.h | 105 ++ drivers/gpu/drm/sti/sti_vid.c | 259 +++++ drivers/gpu/drm/sti/sti_vid.h | 34 + drivers/gpu/drm/sti/sti_vtac_rx.c | 140 +++ drivers/gpu/drm/sti/sti_vtac_tx.c | 152 +++ drivers/gpu/drm/sti/sti_vtac_utils.h | 52 + drivers/gpu/drm/sti/sti_vtg.c | 438 ++++++++ drivers/gpu/drm/sti/sti_vtg.h | 20 + drivers/gpu/drm/sti/sti_vtg_utils.c | 99 ++ drivers/gpu/drm/sti/sti_vtg_utils.h | 29 + 44 files changed, 10303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpu/st,stih4xx.txt create mode 100644 drivers/gpu/drm/sti/Kconfig create mode 100644 drivers/gpu/drm/sti/Makefile create mode 100644 drivers/gpu/drm/sti/sti_compositor.c create mode 100644 drivers/gpu/drm/sti/sti_compositor.h create mode 100644 drivers/gpu/drm/sti/sti_ddc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.c create mode 100644 drivers/gpu/drm/sti/sti_drm_connector.h create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c create mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c create mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.c create mode 100644 drivers/gpu/drm/sti/sti_drm_encoder.h create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c create mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h create mode 100644 drivers/gpu/drm/sti/sti_gdp.c create mode 100644 drivers/gpu/drm/sti/sti_gdp.h create mode 100644 drivers/gpu/drm/sti/sti_hda.c create mode 100644 drivers/gpu/drm/sti/sti_hda.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi.h create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g0c55phy.c create mode 100644 drivers/gpu/drm/sti/sti_hdmi_tx3g4c28phy.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.c create mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h create mode 100644 drivers/gpu/drm/sti/sti_hqvdp_lut.h create mode 100644 drivers/gpu/drm/sti/sti_layer.c create mode 100644 drivers/gpu/drm/sti/sti_layer.h create mode 100644 drivers/gpu/drm/sti/sti_mixer.c create mode 100644 drivers/gpu/drm/sti/sti_mixer.h create mode 100644 drivers/gpu/drm/sti/sti_tvout.c create mode 100644 drivers/gpu/drm/sti/sti_tvout.h create mode 100644 drivers/gpu/drm/sti/sti_vid.c create mode 100644 drivers/gpu/drm/sti/sti_vid.h create mode 100644 drivers/gpu/drm/sti/sti_vtac_rx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_tx.c create mode 100644 drivers/gpu/drm/sti/sti_vtac_utils.h create mode 100644 drivers/gpu/drm/sti/sti_vtg.c create mode 100644 drivers/gpu/drm/sti/sti_vtg.h create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.c create mode 100644 drivers/gpu/drm/sti/sti_vtg_utils.h--
1.9.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 8 lines
--
Benjamin GaignardGraphic Working Group
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Quoted 8 lines
--
Benjamin GaignardGraphic Working Group
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel