Changes in 4.9.337 mm/khugepaged: fix GUP-fast interaction by sending IPI mm/khugepaged: invoke MMU notifiers in shmem/file collapse paths block: unhash blkdev part inode when the part is deleted ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx() can: sja1000: fix size of OCR_MODE_MASK define ASoC: ops: Correct bounds check for second channel on SX controls udf: Discard preallocation before extending file with a hole udf: Drop unused arguments of udf_delete_aext() udf: Fix preallocation discarding at indirect extent boundary udf: Do not bother looking for prealloc extents if i_lenExtents matches i_size udf: Fix extending file within last block usb: gadget: uvc: Prevent buffer overflow in setup handler USB: serial: cp210x: add Kamstrup RF sniffer PIDs Bluetooth: L2CAP: Fix u8 overflow net: loopback: use NET_NAME_PREDICTABLE for name_assign_type drivers: soc: ti: knav_qmss_queue: Mark knav_acc_firmwares as static arm: dts: spear600: Fix clcd interrupt soc: ti: smartreflex: Fix PM disable depth imbalance in omap_sr_probe ARM: dts: dove: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-370: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-xp: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-375: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-38x: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-39x: Fix assigned-addresses for every PCIe Root Port ARM: mmp: fix timer_read delay pstore: Avoid kcore oops by vmap()ing with VM_IOREMAP cpuidle: dt: Return the correct numbers of parsed idle states alpha: fix syscall entry in !AUDUT_SYSCALL case PM: hibernate: Fix mistake in kerneldoc comment fs: don't audit the capability check in simple_xattr_list() perf: Fix possible memleak in pmu_dev_alloc() timerqueue: Use rb_entry_safe() in timerqueue_getnext() ocfs2: fix memory leak in ocfs2_stack_glue_init() MIPS: vpe-mt: fix possible memory leak while module exiting MIPS: vpe-cmp: fix possible memory leak while module exiting PNP: fix name memory leak in pnp_alloc_dev() irqchip: gic-pm: Use pm_runtime_resume_and_get() in gic_probe() libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value lib/notifier-error-inject: fix error when writing -errno to debugfs file rapidio: fix possible name leaks when rio_add_device() fails rapidio: rio: fix possible name leak in rio_register_mport() ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage() uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix x86/xen: Fix memory leak in xen_init_lock_cpu() MIPS: BCM63xx: Add check for NULL for clk in clk_enable fs: sysv: Fix sysv_nblocks() returns wrong value rapidio: fix possible UAF when kfifo_alloc() fails eventfd: change int to __u64 in eventfd_signal() ifndef CONFIG_EVENTFD hfs: Fix OOB Write in hfs_asc2mac rapidio: devices: fix missing put_device in mport_cdev_open wifi: ath9k: hif_usb: fix memory leak of urbs in ath9k_hif_usb_dealloc_tx_urbs() wifi: ath9k: hif_usb: Fix use-after-free in ath9k_hif_usb_reg_in_cb() media: i2c: ad5820: Fix error path media: vivid: fix compose size exceed boundary mtd: Fix device name leak when register device failed in add_mtd_device() ASoC: pxa: fix null-pointer dereference in filter() regulator: core: fix unbalanced of node refcount in regulator_dev_lookup() ima: Fix misuse of dereference of pointer in template_desc_init_fields() wifi: ath10k: Fix return value in ath10k_pci_init() mtd: lpddr2_nvm: Fix possible null-ptr-deref Input: elants_i2c - properly handle the reset GPIO when power is off media: solo6x10: fix possible memory leak in solo_sysfs_init() media: platform: exynos4-is: Fix error handling in fimc_md_init() HID: hid-sensor-custom: set fixed size for custom attributes ALSA: seq: fix undefined behavior in bit shift for SNDRV_SEQ_FILTER_USE_EVENT clk: rockchip: Fix memory leak in rockchip_clk_register_pll() mtd: maps: pxa2xx-flash: fix memory leak in probe media: imon: fix a race condition in send_packet() pinctrl: pinconf-generic: add missing of_node_put() media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer() NFSv4.2: Fix a memory stomp in decode_attr_security_label NFSv4: Fix a deadlock between nfs4_open_recover_helper() and delegreturn ALSA: asihpi: fix missing pci_disable_device() drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios() drm/amdgpu: Fix PCI device refcount leak in amdgpu_atrm_get_bios() ASoC: pcm512x: Fix PM disable depth imbalance in pcm512x_probe bonding: uninitialized variable in bond_miimon_inspect() regulator: core: fix module refcount leak in set_supply() media: saa7164: fix missing pci_disable_device() ALSA: mts64: fix possible null-ptr-defer in snd_mts64_interrupt SUNRPC: Fix missing release socket in rpc_sockname() mmc: moxart: fix return value check of mmc_add_host() mmc: mxcmmc: fix return value check of mmc_add_host() mmc: rtsx_usb_sdmmc: fix return value check of mmc_add_host() mmc: toshsd: fix return value check of mmc_add_host() mmc: vub300: fix return value check of mmc_add_host() mmc: via-sdmmc: fix return value check of mmc_add_host() mmc: wbsd: fix return value check of mmc_add_host() mmc: mmci: fix return value check of mmc_add_host() media: c8sectpfe: Add of_node_put() when breaking out of loop media: coda: Add check for dcoda_iram_alloc media: coda: Add check for kmalloc wifi: rtl8xxxu: Add __packed to struct rtl8723bu_c2h wifi: brcmfmac: Fix error return code in brcmf_sdio_download_firmware() blktrace: Fix output non-blktrace event when blk_classic option enabled net: vmw_vsock: vmci: Check memcpy_from_msg() net: defxx: Fix missing err handling in dfx_init() drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init() ethernet: s2io: don't call dev_kfree_skb() under spin_lock_irqsave() net: farsync: Fix kmemleak when rmmods farsync net/tunnel: wait until all sk_user_data reader finish before releasing the sock net: apple: mace: don't call dev_kfree_skb() under spin_lock_irqsave() net: apple: bmac: don't call dev_kfree_skb() under spin_lock_irqsave() net: emaclite: don't call dev_kfree_skb() under spin_lock_irqsave() net: ethernet: dnet: don't call dev_kfree_skb() under spin_lock_irqsave() hamradio: don't call dev_kfree_skb() under spin_lock_irqsave() net: amd: lance: don't call dev_kfree_skb() under spin_lock_irqsave() ntb_netdev: Use dev_kfree_skb_any() in interrupt context Bluetooth: btusb: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_qca: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_h5: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_bcsp: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_core: don't call kfree_skb() under spin_lock_irqsave() stmmac: fix potential division by 0 scsi: hpsa: Fix error handling in hpsa_add_sas_host() scsi: hpsa: Fix possible memory leak in hpsa_add_sas_device() scsi: fcoe: Fix possible name leak when device_register() fails scsi: ipr: Fix WARNING in ipr_init() scsi: fcoe: Fix transport not deattached when fcoe_if_init() fails scsi: snic: Fix possible UAF in snic_tgt_create() orangefs: Fix sysfs not cleanup when dev init failed crypto: img-hash - Fix variable dereferenced before check 'hdev->req' hwrng: amd - Fix PCI device refcount leak hwrng: geode - Fix PCI device refcount leak IB/IPoIB: Fix queue count inconsistency for PKEY child interfaces drivers: dio: fix possible memory leak in dio_init() vfio: platform: Do not pass return buffer to ACPI _RST method uio: uio_dmem_genirq: Fix missing unlock in irq configuration uio: uio_dmem_genirq: Fix deadlock between irq config and handling usb: fotg210-udc: Fix ages old endianness issues staging: vme_user: Fix possible UAF in tsi148_dma_list_add serial: amba-pl011: avoid SBSA UART accessing DMACR register serial: pch: Fix PCI device refcount leak in pch_request_dma() serial: sunsab: Fix error handling in sunsab_init() misc: tifm: fix possible memory leak in tifm_7xx1_switch_media() misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and gru_handle_user_call_os cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter() cxl: fix possible null-ptr-deref in cxl_pci_init_afu|adapter() drivers: mcb: fix resource leak in mcb_probe() mcb: mcb-parse: fix error handing in chameleon_parse_gdd() chardev: fix error handling in cdev_device_add() i2c: pxa-pci: fix missing pci_disable_device() on error in ce4100_i2c_probe staging: rtl8192u: Fix use after free in ieee80211_rx() staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor() vme: Fix error not catched in fake_init() i2c: ismt: Fix an out-of-bounds bug in ismt_access() usb: storage: Add check for kcalloc fbdev: ssd1307fb: Drop optional dependency fbdev: pm2fb: fix missing pci_disable_device() fbdev: via: Fix error in via_core_init() fbdev: vermilion: decrease reference count in error path fbdev: uvesafb: Fixes an error handling path in uvesafb_probe() HSI: omap_ssi_core: fix unbalanced pm_runtime_disable() HSI: omap_ssi_core: fix possible memory leak in ssi_probe() power: supply: fix residue sysfs file in error handle route of __power_supply_register() HSI: omap_ssi_core: Fix error handling in ssi_init() include/uapi/linux/swab: Fix potentially missing __always_inline rtc: snvs: Allow a time difference on clock register read iommu/fsl_pamu: Fix resource leak in fsl_pamu_probe() macintosh: fix possible memory leak in macio_add_one_device() macintosh/macio-adb: check the return value of ioremap() powerpc/52xx: Fix a resource leak in an error handling path powerpc/perf: callchain validate kernel stack pointer bounds powerpc/83xx/mpc832x_rdb: call platform_device_put() in error case in of_fsl_spi_probe() powerpc/hv-gpci: Fix hv_gpci event list selftests/powerpc: Fix resource leaks rtc: st-lpc: Add missing clk_disable_unprepare in st_rtc_probe() nfsd: under NFSv4.1, fix double svc_xprt_put on rpc_create failure mISDN: hfcsusb: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() mISDN: hfcpci: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() mISDN: hfcmulti: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() nfc: pn533: Clear nfc_target before being used r6040: Fix kmemleak in probe and remove openvswitch: Fix flow lookup to use unmasked key skbuff: Account for tail adjustment during pull operations net_sched: reject TCF_EM_SIMPLE case for complex ematch module myri10ge: Fix an error handling path in myri10ge_probe() net: stream: purge sk_error_queue in sk_stream_kill_queues() binfmt_misc: fix shift-out-of-bounds in check_special_flags fs: jfs: fix shift-out-of-bounds in dbAllocAG udf: Avoid double brelse() in udf_rename() fs: jfs: fix shift-out-of-bounds in dbDiscardAG ACPICA: Fix error code path in acpi_ds_call_control_method() nilfs2: fix shift-out-of-bounds/overflow in nilfs_sb2_bad_offset() acct: fix potential integer overflow in encode_comp_t() hfs: fix OOB Read in __hfs_brec_find wifi: ath9k: verify the expected usb_endpoints are present wifi: ar5523: Fix use-after-free on ar5523_cmd() timed out ipmi: fix memleak when unload ipmi driver net: ethernet: ti: Fix return type of netcp_ndo_start_xmit() hamradio: baycom_epp: Fix return type of baycom_send_packet() wifi: brcmfmac: Fix potential shift-out-of-bounds in brcmf_fw_alloc_request() igb: Do not free q_vector unless new one was allocated s390/ctcm: Fix return type of ctc{mp,}m_tx() s390/netiucv: Fix return type of netiucv_tx() s390/lcs: Fix return type of lcs_start_xmit() drm/sti: Use drm_mode_copy() md/raid1: stop mdx_raid1 thread when raid1 array run failed mrp: introduce active flags to prevent UAF when applicant uninit ppp: associate skb with a device at tx media: dvb-frontends: fix leak of memory fw media: dvb-usb: fix memory leak in dvb_usb_adapter_init() blk-mq: fix possible memleak when register 'hctx' failed mmc: f-sdh30: Add quirks for broken timeout clock capability media: si470x: Fix use-after-free in si470x_int_in_callback() clk: st: Fix memory leak in st_of_quadfs_setup() drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() drm/sti: Fix return type of sti_{dvo,hda,hdmi}_connector_mode_valid() orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() ASoC: mediatek: mt8173-rt5650-rt5514: fix refcount leak in mt8173_rt5650_rt5514_dev_probe() ASoC: wm8994: Fix potential deadlock ASoC: rockchip: spdif: Add missing clk_disable_unprepare() in rk_spdif_runtime_resume() ASoC: rt5670: Remove unbalanced pm_runtime_put() HID: wacom: Ensure bootloader PID is usable in hidraw mode reiserfs: Add missing calls to reiserfs_security_free() iio: adc: ad_sigma_delta: do not use internal iio_dev lock gcov: add support for checksum field powerpc/rtas: avoid scheduling in rtas_os_term() HID: plantronics: Additional PIDs for double volume key presses quirk hfsplus: fix bug causing custom uid and gid being unable to be assigned with mount ALSA: line6: correct midi status byte when receiving data from podxt ALSA: line6: fix stack overflow in line6_midi_transmit pnode: terminate at peers of source md: fix a crash in mempool_free mmc: vub300: fix warning - do not call blocking ops when !TASK_RUNNING media: stv0288: use explicitly signed char ktest.pl minconfig: Unset configs instead of just removing them ARM: ux500: do not directly dereference __iomem dm cache: Fix ABBA deadlock between shrink_slab and dm_cache_metadata_abort dm thin: Use last transaction's pmd->root when commit failed dm thin: Fix UAF in run_timer_softirq() dm cache: Fix UAF in destroy() dm cache: set needs_check flag after aborting metadata tracing: Fix infinite loop in tracing_read_pipe on overflowed print_trace_line ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod media: dvb-core: Fix double free in dvb_register_device() cifs: fix confusing debug message PCI/sysfs: Fix double free in error path crypto: n2 - add missing hash statesize iommu/amd: Fix ivrs_acpihid cmdline parsing code parisc: led: Fix potential null-ptr-deref in start_task() device_cgroup: Roll back to original exceptions after copy failure drm/connector: send hotplug uevent on connector cleanup drm/vmwgfx: Validate the box size for the snooped cursor ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop ext4: fix undefined behavior in bit shift for ext4_check_flag_values ext4: fix bug_on in __es_tree_search caused by bad boot loader inode ext4: init quota for 'old.inode' in 'ext4_rename' ext4: fix error code return to user-space in ext4_get_branch() ext4: avoid BUG_ON when creating xattrs ext4: initialize quota before expanding inode in setproject ioctl Linux 4.9.337 Change-Id: I923e3fef499ae1688b25c70a1a805b55a9f4f027 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
617 lines
15 KiB
C
617 lines
15 KiB
C
/*
|
|
* Copyright (C) STMicroelectronics SA 2014
|
|
* Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
|
|
* License terms: GNU General Public License (GPL), version 2
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/component.h>
|
|
#include <linux/debugfs.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_crtc_helper.h>
|
|
#include <drm/drm_panel.h>
|
|
|
|
#include "sti_awg_utils.h"
|
|
#include "sti_drv.h"
|
|
#include "sti_mixer.h"
|
|
|
|
/* DVO registers */
|
|
#define DVO_AWG_DIGSYNC_CTRL 0x0000
|
|
#define DVO_DOF_CFG 0x0004
|
|
#define DVO_LUT_PROG_LOW 0x0008
|
|
#define DVO_LUT_PROG_MID 0x000C
|
|
#define DVO_LUT_PROG_HIGH 0x0010
|
|
#define DVO_DIGSYNC_INSTR_I 0x0100
|
|
|
|
#define DVO_AWG_CTRL_EN BIT(0)
|
|
#define DVO_AWG_FRAME_BASED_SYNC BIT(2)
|
|
|
|
#define DVO_DOF_EN_LOWBYTE BIT(0)
|
|
#define DVO_DOF_EN_MIDBYTE BIT(1)
|
|
#define DVO_DOF_EN_HIGHBYTE BIT(2)
|
|
#define DVO_DOF_EN BIT(6)
|
|
#define DVO_DOF_MOD_COUNT_SHIFT 8
|
|
|
|
#define DVO_LUT_ZERO 0
|
|
#define DVO_LUT_Y_G 1
|
|
#define DVO_LUT_Y_G_DEL 2
|
|
#define DVO_LUT_CB_B 3
|
|
#define DVO_LUT_CB_B_DEL 4
|
|
#define DVO_LUT_CR_R 5
|
|
#define DVO_LUT_CR_R_DEL 6
|
|
#define DVO_LUT_HOLD 7
|
|
|
|
struct dvo_config {
|
|
u32 flags;
|
|
u32 lowbyte;
|
|
u32 midbyte;
|
|
u32 highbyte;
|
|
int (*awg_fwgen_fct)(
|
|
struct awg_code_generation_params *fw_gen_params,
|
|
struct awg_timing *timing);
|
|
};
|
|
|
|
static struct dvo_config rgb_24bit_de_cfg = {
|
|
.flags = (0L << DVO_DOF_MOD_COUNT_SHIFT),
|
|
.lowbyte = DVO_LUT_CR_R,
|
|
.midbyte = DVO_LUT_Y_G,
|
|
.highbyte = DVO_LUT_CB_B,
|
|
.awg_fwgen_fct = sti_awg_generate_code_data_enable_mode,
|
|
};
|
|
|
|
/**
|
|
* STI digital video output structure
|
|
*
|
|
* @dev: driver device
|
|
* @drm_dev: pointer to drm device
|
|
* @mode: current display mode selected
|
|
* @regs: dvo registers
|
|
* @clk_pix: pixel clock for dvo
|
|
* @clk: clock for dvo
|
|
* @clk_main_parent: dvo parent clock if main path used
|
|
* @clk_aux_parent: dvo parent clock if aux path used
|
|
* @panel_node: panel node reference from device tree
|
|
* @panel: reference to the panel connected to the dvo
|
|
* @enabled: true if dvo is enabled else false
|
|
* @encoder: drm_encoder it is bound
|
|
*/
|
|
struct sti_dvo {
|
|
struct device dev;
|
|
struct drm_device *drm_dev;
|
|
struct drm_display_mode mode;
|
|
void __iomem *regs;
|
|
struct clk *clk_pix;
|
|
struct clk *clk;
|
|
struct clk *clk_main_parent;
|
|
struct clk *clk_aux_parent;
|
|
struct device_node *panel_node;
|
|
struct drm_panel *panel;
|
|
struct dvo_config *config;
|
|
bool enabled;
|
|
struct drm_encoder *encoder;
|
|
struct drm_bridge *bridge;
|
|
};
|
|
|
|
struct sti_dvo_connector {
|
|
struct drm_connector drm_connector;
|
|
struct drm_encoder *encoder;
|
|
struct sti_dvo *dvo;
|
|
};
|
|
|
|
#define to_sti_dvo_connector(x) \
|
|
container_of(x, struct sti_dvo_connector, drm_connector)
|
|
|
|
#define BLANKING_LEVEL 16
|
|
static int dvo_awg_generate_code(struct sti_dvo *dvo, u8 *ram_size, u32 *ram_code)
|
|
{
|
|
struct drm_display_mode *mode = &dvo->mode;
|
|
struct dvo_config *config = dvo->config;
|
|
struct awg_code_generation_params fw_gen_params;
|
|
struct awg_timing timing;
|
|
|
|
fw_gen_params.ram_code = ram_code;
|
|
fw_gen_params.instruction_offset = 0;
|
|
|
|
timing.total_lines = mode->vtotal;
|
|
timing.active_lines = mode->vdisplay;
|
|
timing.blanking_lines = mode->vsync_start - mode->vdisplay;
|
|
timing.trailing_lines = mode->vtotal - mode->vsync_start;
|
|
timing.total_pixels = mode->htotal;
|
|
timing.active_pixels = mode->hdisplay;
|
|
timing.blanking_pixels = mode->hsync_start - mode->hdisplay;
|
|
timing.trailing_pixels = mode->htotal - mode->hsync_start;
|
|
timing.blanking_level = BLANKING_LEVEL;
|
|
|
|
if (config->awg_fwgen_fct(&fw_gen_params, &timing)) {
|
|
DRM_ERROR("AWG firmware not properly generated\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
*ram_size = fw_gen_params.instruction_offset;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Configure AWG, writing instructions
|
|
*
|
|
* @dvo: pointer to DVO structure
|
|
* @awg_ram_code: pointer to AWG instructions table
|
|
* @nb: nb of AWG instructions
|
|
*/
|
|
static void dvo_awg_configure(struct sti_dvo *dvo, u32 *awg_ram_code, int nb)
|
|
{
|
|
int i;
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
for (i = 0; i < nb; i++)
|
|
writel(awg_ram_code[i],
|
|
dvo->regs + DVO_DIGSYNC_INSTR_I + i * 4);
|
|
for (i = nb; i < AWG_MAX_INST; i++)
|
|
writel(0, dvo->regs + DVO_DIGSYNC_INSTR_I + i * 4);
|
|
|
|
writel(DVO_AWG_CTRL_EN, dvo->regs + DVO_AWG_DIGSYNC_CTRL);
|
|
}
|
|
|
|
#define DBGFS_DUMP(reg) seq_printf(s, "\n %-25s 0x%08X", #reg, \
|
|
readl(dvo->regs + reg))
|
|
|
|
static void dvo_dbg_awg_microcode(struct seq_file *s, void __iomem *reg)
|
|
{
|
|
unsigned int i;
|
|
|
|
seq_puts(s, "\n\n");
|
|
seq_puts(s, " DVO AWG microcode:");
|
|
for (i = 0; i < AWG_MAX_INST; i++) {
|
|
if (i % 8 == 0)
|
|
seq_printf(s, "\n %04X:", i);
|
|
seq_printf(s, " %04X", readl(reg + i * 4));
|
|
}
|
|
}
|
|
|
|
static int dvo_dbg_show(struct seq_file *s, void *data)
|
|
{
|
|
struct drm_info_node *node = s->private;
|
|
struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data;
|
|
|
|
seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs);
|
|
DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL);
|
|
DBGFS_DUMP(DVO_DOF_CFG);
|
|
DBGFS_DUMP(DVO_LUT_PROG_LOW);
|
|
DBGFS_DUMP(DVO_LUT_PROG_MID);
|
|
DBGFS_DUMP(DVO_LUT_PROG_HIGH);
|
|
dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I);
|
|
seq_puts(s, "\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct drm_info_list dvo_debugfs_files[] = {
|
|
{ "dvo", dvo_dbg_show, 0, NULL },
|
|
};
|
|
|
|
static void dvo_debugfs_exit(struct sti_dvo *dvo, struct drm_minor *minor)
|
|
{
|
|
drm_debugfs_remove_files(dvo_debugfs_files,
|
|
ARRAY_SIZE(dvo_debugfs_files),
|
|
minor);
|
|
}
|
|
|
|
static int dvo_debugfs_init(struct sti_dvo *dvo, struct drm_minor *minor)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dvo_debugfs_files); i++)
|
|
dvo_debugfs_files[i].data = dvo;
|
|
|
|
return drm_debugfs_create_files(dvo_debugfs_files,
|
|
ARRAY_SIZE(dvo_debugfs_files),
|
|
minor->debugfs_root, minor);
|
|
}
|
|
|
|
static void sti_dvo_disable(struct drm_bridge *bridge)
|
|
{
|
|
struct sti_dvo *dvo = bridge->driver_private;
|
|
|
|
if (!dvo->enabled)
|
|
return;
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
if (dvo->config->awg_fwgen_fct)
|
|
writel(0x00000000, dvo->regs + DVO_AWG_DIGSYNC_CTRL);
|
|
|
|
writel(0x00000000, dvo->regs + DVO_DOF_CFG);
|
|
|
|
if (dvo->panel)
|
|
dvo->panel->funcs->disable(dvo->panel);
|
|
|
|
/* Disable/unprepare dvo clock */
|
|
clk_disable_unprepare(dvo->clk_pix);
|
|
clk_disable_unprepare(dvo->clk);
|
|
|
|
dvo->enabled = false;
|
|
}
|
|
|
|
static void sti_dvo_pre_enable(struct drm_bridge *bridge)
|
|
{
|
|
struct sti_dvo *dvo = bridge->driver_private;
|
|
struct dvo_config *config = dvo->config;
|
|
u32 val;
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
if (dvo->enabled)
|
|
return;
|
|
|
|
/* Make sure DVO is disabled */
|
|
writel(0x00000000, dvo->regs + DVO_DOF_CFG);
|
|
writel(0x00000000, dvo->regs + DVO_AWG_DIGSYNC_CTRL);
|
|
|
|
if (config->awg_fwgen_fct) {
|
|
u8 nb_instr;
|
|
u32 awg_ram_code[AWG_MAX_INST];
|
|
/* Configure AWG */
|
|
if (!dvo_awg_generate_code(dvo, &nb_instr, awg_ram_code))
|
|
dvo_awg_configure(dvo, awg_ram_code, nb_instr);
|
|
else
|
|
return;
|
|
}
|
|
|
|
/* Prepare/enable clocks */
|
|
if (clk_prepare_enable(dvo->clk_pix))
|
|
DRM_ERROR("Failed to prepare/enable dvo_pix clk\n");
|
|
if (clk_prepare_enable(dvo->clk))
|
|
DRM_ERROR("Failed to prepare/enable dvo clk\n");
|
|
|
|
if (dvo->panel)
|
|
dvo->panel->funcs->enable(dvo->panel);
|
|
|
|
/* Set LUT */
|
|
writel(config->lowbyte, dvo->regs + DVO_LUT_PROG_LOW);
|
|
writel(config->midbyte, dvo->regs + DVO_LUT_PROG_MID);
|
|
writel(config->highbyte, dvo->regs + DVO_LUT_PROG_HIGH);
|
|
|
|
/* Digital output formatter config */
|
|
val = (config->flags | DVO_DOF_EN);
|
|
writel(val, dvo->regs + DVO_DOF_CFG);
|
|
|
|
dvo->enabled = true;
|
|
}
|
|
|
|
static void sti_dvo_set_mode(struct drm_bridge *bridge,
|
|
struct drm_display_mode *mode,
|
|
struct drm_display_mode *adjusted_mode)
|
|
{
|
|
struct sti_dvo *dvo = bridge->driver_private;
|
|
struct sti_mixer *mixer = to_sti_mixer(dvo->encoder->crtc);
|
|
int rate = mode->clock * 1000;
|
|
struct clk *clkp;
|
|
int ret;
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
drm_mode_copy(&dvo->mode, mode);
|
|
|
|
/* According to the path used (main or aux), the dvo clocks should
|
|
* have a different parent clock. */
|
|
if (mixer->id == STI_MIXER_MAIN)
|
|
clkp = dvo->clk_main_parent;
|
|
else
|
|
clkp = dvo->clk_aux_parent;
|
|
|
|
if (clkp) {
|
|
clk_set_parent(dvo->clk_pix, clkp);
|
|
clk_set_parent(dvo->clk, clkp);
|
|
}
|
|
|
|
/* DVO clocks = compositor clock */
|
|
ret = clk_set_rate(dvo->clk_pix, rate);
|
|
if (ret < 0) {
|
|
DRM_ERROR("Cannot set rate (%dHz) for dvo_pix clk\n", rate);
|
|
return;
|
|
}
|
|
|
|
ret = clk_set_rate(dvo->clk, rate);
|
|
if (ret < 0) {
|
|
DRM_ERROR("Cannot set rate (%dHz) for dvo clk\n", rate);
|
|
return;
|
|
}
|
|
|
|
/* For now, we only support 24bit data enable (DE) synchro format */
|
|
dvo->config = &rgb_24bit_de_cfg;
|
|
}
|
|
|
|
static void sti_dvo_bridge_nope(struct drm_bridge *bridge)
|
|
{
|
|
/* do nothing */
|
|
}
|
|
|
|
static const struct drm_bridge_funcs sti_dvo_bridge_funcs = {
|
|
.pre_enable = sti_dvo_pre_enable,
|
|
.enable = sti_dvo_bridge_nope,
|
|
.disable = sti_dvo_disable,
|
|
.post_disable = sti_dvo_bridge_nope,
|
|
.mode_set = sti_dvo_set_mode,
|
|
};
|
|
|
|
static int sti_dvo_connector_get_modes(struct drm_connector *connector)
|
|
{
|
|
struct sti_dvo_connector *dvo_connector
|
|
= to_sti_dvo_connector(connector);
|
|
struct sti_dvo *dvo = dvo_connector->dvo;
|
|
|
|
if (dvo->panel)
|
|
return dvo->panel->funcs->get_modes(dvo->panel);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#define CLK_TOLERANCE_HZ 50
|
|
|
|
static enum drm_mode_status
|
|
sti_dvo_connector_mode_valid(struct drm_connector *connector,
|
|
struct drm_display_mode *mode)
|
|
{
|
|
int target = mode->clock * 1000;
|
|
int target_min = target - CLK_TOLERANCE_HZ;
|
|
int target_max = target + CLK_TOLERANCE_HZ;
|
|
int result;
|
|
struct sti_dvo_connector *dvo_connector
|
|
= to_sti_dvo_connector(connector);
|
|
struct sti_dvo *dvo = dvo_connector->dvo;
|
|
|
|
result = clk_round_rate(dvo->clk_pix, target);
|
|
|
|
DRM_DEBUG_DRIVER("target rate = %d => available rate = %d\n",
|
|
target, result);
|
|
|
|
if ((result < target_min) || (result > target_max)) {
|
|
DRM_DEBUG_DRIVER("dvo pixclk=%d not supported\n", target);
|
|
return MODE_BAD;
|
|
}
|
|
|
|
return MODE_OK;
|
|
}
|
|
|
|
static const
|
|
struct drm_connector_helper_funcs sti_dvo_connector_helper_funcs = {
|
|
.get_modes = sti_dvo_connector_get_modes,
|
|
.mode_valid = sti_dvo_connector_mode_valid,
|
|
};
|
|
|
|
static enum drm_connector_status
|
|
sti_dvo_connector_detect(struct drm_connector *connector, bool force)
|
|
{
|
|
struct sti_dvo_connector *dvo_connector
|
|
= to_sti_dvo_connector(connector);
|
|
struct sti_dvo *dvo = dvo_connector->dvo;
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
if (!dvo->panel) {
|
|
dvo->panel = of_drm_find_panel(dvo->panel_node);
|
|
if (dvo->panel)
|
|
drm_panel_attach(dvo->panel, connector);
|
|
}
|
|
|
|
if (dvo->panel)
|
|
return connector_status_connected;
|
|
|
|
return connector_status_disconnected;
|
|
}
|
|
|
|
static int sti_dvo_late_register(struct drm_connector *connector)
|
|
{
|
|
struct sti_dvo_connector *dvo_connector
|
|
= to_sti_dvo_connector(connector);
|
|
struct sti_dvo *dvo = dvo_connector->dvo;
|
|
|
|
if (dvo_debugfs_init(dvo, dvo->drm_dev->primary)) {
|
|
DRM_ERROR("DVO debugfs setup failed\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct drm_connector_funcs sti_dvo_connector_funcs = {
|
|
.dpms = drm_atomic_helper_connector_dpms,
|
|
.fill_modes = drm_helper_probe_single_connector_modes,
|
|
.detect = sti_dvo_connector_detect,
|
|
.destroy = drm_connector_cleanup,
|
|
.reset = drm_atomic_helper_connector_reset,
|
|
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
|
|
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
|
|
.late_register = sti_dvo_late_register,
|
|
};
|
|
|
|
static struct drm_encoder *sti_dvo_find_encoder(struct drm_device *dev)
|
|
{
|
|
struct drm_encoder *encoder;
|
|
|
|
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
|
|
if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS)
|
|
return encoder;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
|
|
{
|
|
struct sti_dvo *dvo = dev_get_drvdata(dev);
|
|
struct drm_device *drm_dev = data;
|
|
struct drm_encoder *encoder;
|
|
struct sti_dvo_connector *connector;
|
|
struct drm_connector *drm_connector;
|
|
struct drm_bridge *bridge;
|
|
int err;
|
|
|
|
/* Set the drm device handle */
|
|
dvo->drm_dev = drm_dev;
|
|
|
|
encoder = sti_dvo_find_encoder(drm_dev);
|
|
if (!encoder)
|
|
return -ENOMEM;
|
|
|
|
connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
|
|
if (!connector)
|
|
return -ENOMEM;
|
|
|
|
connector->dvo = dvo;
|
|
|
|
bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
|
|
if (!bridge)
|
|
return -ENOMEM;
|
|
|
|
bridge->driver_private = dvo;
|
|
bridge->funcs = &sti_dvo_bridge_funcs;
|
|
bridge->of_node = dvo->dev.of_node;
|
|
err = drm_bridge_add(bridge);
|
|
if (err) {
|
|
DRM_ERROR("Failed to add bridge\n");
|
|
return err;
|
|
}
|
|
|
|
err = drm_bridge_attach(drm_dev, bridge);
|
|
if (err) {
|
|
DRM_ERROR("Failed to attach bridge\n");
|
|
return err;
|
|
}
|
|
|
|
dvo->bridge = bridge;
|
|
encoder->bridge = bridge;
|
|
connector->encoder = encoder;
|
|
dvo->encoder = encoder;
|
|
|
|
drm_connector = (struct drm_connector *)connector;
|
|
|
|
drm_connector->polled = DRM_CONNECTOR_POLL_HPD;
|
|
|
|
drm_connector_init(drm_dev, drm_connector,
|
|
&sti_dvo_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
|
|
drm_connector_helper_add(drm_connector,
|
|
&sti_dvo_connector_helper_funcs);
|
|
|
|
err = drm_mode_connector_attach_encoder(drm_connector, encoder);
|
|
if (err) {
|
|
DRM_ERROR("Failed to attach a connector to a encoder\n");
|
|
goto err_sysfs;
|
|
}
|
|
|
|
return 0;
|
|
|
|
err_sysfs:
|
|
drm_bridge_remove(bridge);
|
|
return -EINVAL;
|
|
}
|
|
|
|
static void sti_dvo_unbind(struct device *dev,
|
|
struct device *master, void *data)
|
|
{
|
|
struct sti_dvo *dvo = dev_get_drvdata(dev);
|
|
struct drm_device *drm_dev = data;
|
|
|
|
dvo_debugfs_exit(dvo, drm_dev->primary);
|
|
|
|
drm_bridge_remove(dvo->bridge);
|
|
}
|
|
|
|
static const struct component_ops sti_dvo_ops = {
|
|
.bind = sti_dvo_bind,
|
|
.unbind = sti_dvo_unbind,
|
|
};
|
|
|
|
static int sti_dvo_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct sti_dvo *dvo;
|
|
struct resource *res;
|
|
struct device_node *np = dev->of_node;
|
|
|
|
DRM_INFO("%s\n", __func__);
|
|
|
|
dvo = devm_kzalloc(dev, sizeof(*dvo), GFP_KERNEL);
|
|
if (!dvo) {
|
|
DRM_ERROR("Failed to allocate memory for DVO\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
dvo->dev = pdev->dev;
|
|
|
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dvo-reg");
|
|
if (!res) {
|
|
DRM_ERROR("Invalid dvo resource\n");
|
|
return -ENOMEM;
|
|
}
|
|
dvo->regs = devm_ioremap_nocache(dev, res->start,
|
|
resource_size(res));
|
|
if (!dvo->regs)
|
|
return -ENOMEM;
|
|
|
|
dvo->clk_pix = devm_clk_get(dev, "dvo_pix");
|
|
if (IS_ERR(dvo->clk_pix)) {
|
|
DRM_ERROR("Cannot get dvo_pix clock\n");
|
|
return PTR_ERR(dvo->clk_pix);
|
|
}
|
|
|
|
dvo->clk = devm_clk_get(dev, "dvo");
|
|
if (IS_ERR(dvo->clk)) {
|
|
DRM_ERROR("Cannot get dvo clock\n");
|
|
return PTR_ERR(dvo->clk);
|
|
}
|
|
|
|
dvo->clk_main_parent = devm_clk_get(dev, "main_parent");
|
|
if (IS_ERR(dvo->clk_main_parent)) {
|
|
DRM_DEBUG_DRIVER("Cannot get main_parent clock\n");
|
|
dvo->clk_main_parent = NULL;
|
|
}
|
|
|
|
dvo->clk_aux_parent = devm_clk_get(dev, "aux_parent");
|
|
if (IS_ERR(dvo->clk_aux_parent)) {
|
|
DRM_DEBUG_DRIVER("Cannot get aux_parent clock\n");
|
|
dvo->clk_aux_parent = NULL;
|
|
}
|
|
|
|
dvo->panel_node = of_parse_phandle(np, "sti,panel", 0);
|
|
if (!dvo->panel_node)
|
|
DRM_ERROR("No panel associated to the dvo output\n");
|
|
of_node_put(dvo->panel_node);
|
|
|
|
platform_set_drvdata(pdev, dvo);
|
|
|
|
return component_add(&pdev->dev, &sti_dvo_ops);
|
|
}
|
|
|
|
static int sti_dvo_remove(struct platform_device *pdev)
|
|
{
|
|
component_del(&pdev->dev, &sti_dvo_ops);
|
|
return 0;
|
|
}
|
|
|
|
static struct of_device_id dvo_of_match[] = {
|
|
{ .compatible = "st,stih407-dvo", },
|
|
{ /* end node */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, dvo_of_match);
|
|
|
|
struct platform_driver sti_dvo_driver = {
|
|
.driver = {
|
|
.name = "sti-dvo",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = dvo_of_match,
|
|
},
|
|
.probe = sti_dvo_probe,
|
|
.remove = sti_dvo_remove,
|
|
};
|
|
|
|
MODULE_AUTHOR("Benjamin Gaignard <benjamin.gaignard@st.com>");
|
|
MODULE_DESCRIPTION("STMicroelectronics SoC DRM driver");
|
|
MODULE_LICENSE("GPL");
|