
Changes in 5.10.20 vmlinux.lds.h: add DWARF v5 sections vdpa/mlx5: fix param validation in mlx5_vdpa_get_config() debugfs: be more robust at handling improper input in debugfs_lookup() debugfs: do not attempt to create a new file before the filesystem is initalized scsi: libsas: docs: Remove notify_ha_event() scsi: qla2xxx: Fix mailbox Ch erroneous error kdb: Make memory allocations more robust w1: w1_therm: Fix conversion result for negative temperatures PCI: qcom: Use PHY_REFCLK_USE_PAD only for ipq8064 PCI: Decline to resize resources if boot config must be preserved virt: vbox: Do not use wait_event_interruptible when called from kernel context bfq: Avoid false bfq queue merging ALSA: usb-audio: Fix PCM buffer allocation in non-vmalloc mode MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section vmlinux.lds.h: Define SANTIZER_DISCARDS with CONFIG_GCOV_KERNEL=y random: fix the RNDRESEEDCRNG ioctl ALSA: pcm: Call sync_stop at disconnection ALSA: pcm: Assure sync with the pending stop operation at suspend ALSA: pcm: Don't call sync_stop if it hasn't been stopped drm/i915/gt: One more flush for Baytrail clear residuals ath10k: Fix error handling in case of CE pipe init failure Bluetooth: btqcomsmd: Fix a resource leak in error handling paths in the probe function Bluetooth: hci_uart: Fix a race for write_work scheduling Bluetooth: Fix initializing response id after clearing struct arm64: dts: renesas: beacon kit: Fix choppy Bluetooth Audio arm64: dts: renesas: beacon: Fix audio-1.8V pin enable ARM: dts: exynos: correct PMIC interrupt trigger level on Artik 5 ARM: dts: exynos: correct PMIC interrupt trigger level on Monk ARM: dts: exynos: correct PMIC interrupt trigger level on Rinato ARM: dts: exynos: correct PMIC interrupt trigger level on Spring ARM: dts: exynos: correct PMIC interrupt trigger level on Arndale Octa ARM: dts: exynos: correct PMIC interrupt trigger level on Odroid XU3 family arm64: dts: exynos: correct PMIC interrupt trigger level on TM2 arm64: dts: exynos: correct PMIC interrupt trigger level on Espresso memory: mtk-smi: Fix PM usage counter unbalance in mtk_smi ops Bluetooth: hci_qca: Fix memleak in qca_controller_memdump staging: vchiq: Fix bulk userdata handling staging: vchiq: Fix bulk transfers on 64-bit builds arm64: dts: qcom: msm8916-samsung-a5u: Fix iris compatible net: stmmac: dwmac-meson8b: fix enabling the timing-adjustment clock bpf: Add bpf_patch_call_args prototype to include/linux/bpf.h bpf: Avoid warning when re-casting __bpf_call_base into __bpf_call_base_args firmware: arm_scmi: Fix call site of scmi_notification_exit arm64: dts: allwinner: A64: properly connect USB PHY to port 0 arm64: dts: allwinner: H6: properly connect USB PHY to port 0 arm64: dts: allwinner: Drop non-removable from SoPine/LTS SD card arm64: dts: allwinner: H6: Allow up to 150 MHz MMC bus frequency arm64: dts: allwinner: A64: Limit MMC2 bus frequency to 150 MHz arm64: dts: qcom: msm8916-samsung-a2015: Fix sensors cpufreq: brcmstb-avs-cpufreq: Free resources in error path cpufreq: brcmstb-avs-cpufreq: Fix resource leaks in ->remove() arm64: dts: rockchip: rk3328: Add clock_in_out property to gmac2phy node ACPICA: Fix exception code class checks usb: gadget: u_audio: Free requests only after callback arm64: dts: qcom: sdm845-db845c: Fix reset-pin of ov8856 node soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() soc: ti: pm33xx: Fix some resource leak in the error handling paths of the probe function staging: media: atomisp: Fix size_t format specifier in hmm_alloc() debug statemenet Bluetooth: drop HCI device reference before return Bluetooth: Put HCI device if inquiry procedure interrupts memory: ti-aemif: Drop child node when jumping out loop ARM: dts: Configure missing thermal interrupt for 4430 usb: dwc2: Do not update data length if it is 0 on inbound transfers usb: dwc2: Abort transaction after errors with unknown reason usb: dwc2: Make "trimming xfer length" a debug message staging: rtl8723bs: wifi_regd.c: Fix incorrect number of regulatory rules x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too arm64: dts: renesas: beacon: Fix EEPROM compatible value can: mcp251xfd: mcp251xfd_probe(): fix errata reference ARM: dts: armada388-helios4: assign pinctrl to LEDs ARM: dts: armada388-helios4: assign pinctrl to each fan arm64: dts: armada-3720-turris-mox: rename u-boot mtd partition to a53-firmware opp: Correct debug message in _opp_add_static_v2() Bluetooth: btusb: Fix memory leak in btusb_mtk_wmt_recv soc: qcom: ocmem: don't return NULL in of_get_ocmem arm64: dts: msm8916: Fix reserved and rfsa nodes unit address arm64: dts: meson: fix broken wifi node for Khadas VIM3L iwlwifi: mvm: set enabled in the PPAG command properly ARM: s3c: fix fiq for clang IAS optee: simplify i2c access staging: wfx: fix possible panic with re-queued frames ARM: at91: use proper asm syntax in pm_suspend ath10k: Fix suspicious RCU usage warning in ath10k_wmi_tlv_parse_peer_stats_info() ath10k: Fix lockdep assertion warning in ath10k_sta_statistics ath11k: fix a locking bug in ath11k_mac_op_start() soc: aspeed: snoop: Add clock control logic iwlwifi: mvm: fix the type we use in the PPAG table validity checks iwlwifi: mvm: store PPAG enabled/disabled flag properly iwlwifi: mvm: send stored PPAG command instead of local iwlwifi: mvm: assign SAR table revision to the command later iwlwifi: mvm: don't check if CSA event is running before removing bpf_lru_list: Read double-checked variable once without lock iwlwifi: pnvm: set the PNVM again if it was already loaded iwlwifi: pnvm: increment the pointer before checking the TLV ath9k: fix data bus crash when setting nf_override via debugfs selftests/bpf: Convert test_xdp_redirect.sh to bash ibmvnic: Set to CLOSED state even on error bnxt_en: reverse order of TX disable and carrier off bnxt_en: Fix devlink info's stored fw.psid version format. xen/netback: fix spurious event detection for common event case dpaa2-eth: fix memory leak in XDP_REDIRECT net: phy: consider that suspend2ram may cut off PHY power net/mlx5e: Don't change interrupt moderation params when DIM is enabled net/mlx5e: Change interrupt moderation channel params also when channels are closed net/mlx5: Fix health error state handling net/mlx5e: Replace synchronize_rcu with synchronize_net net/mlx5e: kTLS, Use refcounts to free kTLS RX priv context net/mlx5: Disable devlink reload for multi port slave device net/mlx5: Disallow RoCE on multi port slave device net/mlx5: Disallow RoCE on lag device net/mlx5: Disable devlink reload for lag devices net/mlx5e: CT: manage the lifetime of the ct entry object net/mlx5e: Check tunnel offload is required before setting SWP mac80211: fix potential overflow when multiplying to u32 integers libbpf: Ignore non function pointer member in struct_ops bpf: Fix an unitialized value in bpf_iter bpf, devmap: Use GFP_KERNEL for xdp bulk queue allocation bpf: Fix bpf_fib_lookup helper MTU check for SKB ctx selftests: mptcp: fix ACKRX debug message tcp: fix SO_RCVLOWAT related hangs under mem pressure net: axienet: Handle deferred probe on clock properly cxgb4/chtls/cxgbit: Keeping the max ofld immediate data size same in cxgb4 and ulds b43: N-PHY: Fix the update of coef for the PHY revision >= 3case bpf: Clear subreg_def for global function return values ibmvnic: add memory barrier to protect long term buffer ibmvnic: skip send_request_unmap for timeout reset net: dsa: felix: perform teardown in reverse order of setup net: dsa: felix: don't deinitialize unused ports net: phy: mscc: adding LCPLL reset to VSC8514 net: amd-xgbe: Reset the PHY rx data path when mailbox command timeout net: amd-xgbe: Fix NETDEV WATCHDOG transmit queue timeout warning net: amd-xgbe: Reset link when the link never comes back net: amd-xgbe: Fix network fluctuations when using 1G BELFUSE SFP net: mvneta: Remove per-cpu queue mapping for Armada 3700 net: enetc: fix destroyed phylink dereference during unbind tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer tty: implement read_iter fbdev: aty: SPARC64 requires FB_ATY_CT drm/gma500: Fix error return code in psb_driver_load() gma500: clean up error handling in init drm/fb-helper: Add missed unlocks in setcmap_legacy() drm/panel: mantix: Tweak init sequence drm/vc4: hdmi: Take into account the clock doubling flag in atomic_check crypto: sun4i-ss - linearize buffers content must be kept crypto: sun4i-ss - fix kmap usage crypto: arm64/aes-ce - really hide slower algos when faster ones are enabled hwrng: ingenic - Fix a resource leak in an error handling path media: allegro: Fix use after free on error kcsan: Rewrite kcsan_prandom_u32_max() without prandom_u32_state() drm: rcar-du: Fix PM reference leak in rcar_cmm_enable() drm: rcar-du: Fix crash when using LVDS1 clock for CRTC drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node drm/amdgpu: Fix macro name _AMDGPU_TRACE_H_ in preprocessor if condition MIPS: c-r4k: Fix section mismatch for loongson2_sc_init MIPS: lantiq: Explicitly compare LTQ_EBU_PCC_ISTAT against 0 drm/virtio: make sure context is created in gem open drm/fourcc: fix Amlogic format modifier masks media: ipu3-cio2: Build only for x86 media: i2c: ov5670: Fix PIXEL_RATE minimum value media: imx: Unregister csc/scaler only if registered media: imx: Fix csc/scaler unregister media: mtk-vcodec: fix error return code in vdec_vp9_decode() media: camss: missing error code in msm_video_register() media: vsp1: Fix an error handling path in the probe function media: em28xx: Fix use-after-free in em28xx_alloc_urbs media: media/pci: Fix memleak in empress_init media: tm6000: Fix memleak in tm6000_start_stream media: aspeed: fix error return code in aspeed_video_setup_video() ASoC: cs42l56: fix up error handling in probe ASoC: qcom: qdsp6: Move frontend AIFs to q6asm-dai evm: Fix memleak in init_desc crypto: bcm - Rename struct device_private to bcm_device_private sched/fair: Avoid stale CPU util_est value for schedutil in task dequeue drm/sun4i: tcon: fix inverted DCLK polarity media: imx7: csi: Fix regression for parallel cameras on i.MX6UL media: imx7: csi: Fix pad link validation media: ti-vpe: cal: fix write to unallocated memory MIPS: properly stop .eh_frame generation MIPS: Compare __SYNC_loongson3_war against 0 drm/tegra: Fix reference leak when pm_runtime_get_sync() fails drm/amdgpu: toggle on DF Cstate after finishing xgmi injection bsg: free the request before return error code macintosh/adb-iop: Use big-endian autopoll mask drm/amd/display: Fix 10/12 bpc setup in DCE output bit depth reduction. drm/amd/display: Fix HDMI deep color output for DCE 6-11. media: software_node: Fix refcounts in software_node_get_next_child() media: lmedm04: Fix misuse of comma media: vidtv: psi: fix missing crc for PMT media: atomisp: Fix a buffer overflow in debug code media: qm1d1c0042: fix error return code in qm1d1c0042_init() media: cx25821: Fix a bug when reallocating some dma memory media: mtk-vcodec: fix argument used when DEBUG is defined media: pxa_camera: declare variable when DEBUG is defined media: uvcvideo: Accept invalid bFormatIndex and bFrameIndex values sched/eas: Don't update misfit status if the task is pinned f2fs: compress: fix potential deadlock ASoC: qcom: lpass-cpu: Remove bit clock state check ASoC: SOF: Intel: hda: cancel D0i3 work during runtime suspend perf/arm-cmn: Fix PMU instance naming perf/arm-cmn: Move IRQs when migrating context mtd: parser: imagetag: fix error codes in bcm963xx_parse_imagetag_partitions() crypto: talitos - Work around SEC6 ERRATA (AES-CTR mode data size error) crypto: talitos - Fix ctr(aes) on SEC1 drm/nouveau: bail out of nouveau_channel_new if channel init fails mm: proc: Invalidate TLB after clearing soft-dirty page state ata: ahci_brcm: Add back regulators management ASoC: cpcap: fix microphone timeslot mask ASoC: codecs: add missing max_register in regmap config mtd: parsers: afs: Fix freeing the part name memory in failure f2fs: fix to avoid inconsistent quota data drm/amdgpu: Prevent shift wrapping in amdgpu_read_mask() f2fs: fix a wrong condition in __submit_bio ASoC: qcom: Fix typo error in HDMI regmap config callbacks KVM: nSVM: Don't strip host's C-bit from guest's CR3 when reading PDPTRs drm/mediatek: Check if fb is null Drivers: hv: vmbus: Avoid use-after-free in vmbus_onoffer_rescind() ASoC: Intel: sof_sdw: add missing TGL_HDMI quirk for Dell SKU 0A5E ASoC: Intel: sof_sdw: add missing TGL_HDMI quirk for Dell SKU 0A3E locking/lockdep: Avoid unmatched unlock ASoC: qcom: lpass: Fix i2s ctl register bit map ASoC: rt5682: Fix panic in rt5682_jack_detect_handler happening during system shutdown ASoC: SOF: debug: Fix a potential issue on string buffer termination btrfs: clarify error returns values in __load_free_space_cache btrfs: fix double accounting of ordered extent for subpage case in btrfs_invalidapge KVM: x86: Restore all 64 bits of DR6 and DR7 during RSM on x86-64 s390/zcrypt: return EIO when msg retry limit reached drm/vc4: hdmi: Move hdmi reset to bind drm/vc4: hdmi: Fix register offset with longer CEC messages drm/vc4: hdmi: Fix up CEC registers drm/vc4: hdmi: Restore cec physical address on reconnect drm/vc4: hdmi: Compute the CEC clock divider from the clock rate drm/vc4: hdmi: Update the CEC clock divider on HSM rate change drm/lima: fix reference leak in lima_pm_busy drm/dp_mst: Don't cache EDIDs for physical ports hwrng: timeriomem - Fix cooldown period calculation crypto: ecdh_helper - Ensure 'len >= secret.len' in decode_key() io_uring: fix possible deadlock in io_uring_poll nvmet-tcp: fix receive data digest calculation for multiple h2cdata PDUs nvmet-tcp: fix potential race of tcp socket closing accept_work nvme-multipath: set nr_zones for zoned namespaces nvmet: remove extra variable in identify ns nvmet: set status to 0 in case for invalid nsid ASoC: SOF: sof-pci-dev: add missing Up-Extreme quirk ima: Free IMA measurement buffer on error ima: Free IMA measurement buffer after kexec syscall ASoC: simple-card-utils: Fix device module clock fs/jfs: fix potential integer overflow on shift of a int jffs2: fix use after free in jffs2_sum_write_data() ubifs: Fix memleak in ubifs_init_authentication ubifs: replay: Fix high stack usage, again ubifs: Fix error return code in alloc_wbufs() irqchip/imx: IMX_INTMUX should not default to y, unconditionally smp: Process pending softirqs in flush_smp_call_function_from_idle() drm/amdgpu/display: remove hdcp_srm sysfs on device removal capabilities: Don't allow writing ambiguous v3 file capabilities HSI: Fix PM usage counter unbalance in ssi_hw_init power: supply: cpcap: Add missing IRQF_ONESHOT to fix regression clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL clk: meson: clk-pll: make "ret" a signed integer clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate() selftests/powerpc: Make the test check in eeh-basic.sh posix compliant regulator: qcom-rpmh-regulator: add pm8009-1 chip revision arm64: dts: qcom: qrb5165-rb5: fix pm8009 regulators quota: Fix memory leak when handling corrupted quota file i2c: iproc: handle only slave interrupts which are enabled i2c: iproc: update slave isr mask (ISR_MASK_SLAVE) i2c: iproc: handle master read request spi: cadence-quadspi: Abort read if dummy cycles required are too many clk: sunxi-ng: h6: Fix CEC clock clk: renesas: r8a779a0: Remove non-existent S2 clock clk: renesas: r8a779a0: Fix parent of CBFUSA clock HID: core: detect and skip invalid inputs to snto32() RDMA/siw: Fix handling of zero-sized Read and Receive Queues. dmaengine: fsldma: Fix a resource leak in the remove function dmaengine: fsldma: Fix a resource leak in an error handling path of the probe function dmaengine: owl-dma: Fix a resource leak in the remove function dmaengine: hsu: disable spurious interrupt mfd: bd9571mwv: Use devm_mfd_add_devices() power: supply: cpcap-charger: Fix missing power_supply_put() power: supply: cpcap-battery: Fix missing power_supply_put() power: supply: cpcap-charger: Fix power_supply_put on null battery pointer fdt: Properly handle "no-map" field in the memory region of/fdt: Make sure no-map does not remove already reserved regions RDMA/rtrs: Extend ibtrs_cq_qp_create RDMA/rtrs-srv: Release lock before call into close_sess RDMA/rtrs-srv: Use sysfs_remove_file_self for disconnect RDMA/rtrs-clt: Set mininum limit when create QP RDMA/rtrs: Call kobject_put in the failure path RDMA/rtrs-srv: Fix missing wr_cqe RDMA/rtrs-clt: Refactor the failure cases in alloc_clt RDMA/rtrs-srv: Init wr_cnt as 1 power: reset: at91-sama5d2_shdwc: fix wkupdbc mask rtc: s5m: select REGMAP_I2C dmaengine: idxd: set DMA channel to be private power: supply: fix sbs-charger build, needs REGMAP_I2C clocksource/drivers/ixp4xx: Select TIMER_OF when needed clocksource/drivers/mxs_timer: Add missing semicolon when DEBUG is defined spi: imx: Don't print error on -EPROBEDEFER RDMA/mlx5: Use the correct obj_id upon DEVX TIR creation IB/mlx5: Add mutex destroy call to cap_mask_mutex mutex clk: sunxi-ng: h6: Fix clock divider range on some clocks platform/chrome: cros_ec_proto: Use EC_HOST_EVENT_MASK not BIT platform/chrome: cros_ec_proto: Add LID and BATTERY to default mask regulator: axp20x: Fix reference cout leak watch_queue: Drop references to /dev/watch_queue certs: Fix blacklist flag type confusion regulator: s5m8767: Fix reference count leak spi: atmel: Put allocated master before return regulator: s5m8767: Drop regulators OF node reference power: supply: axp20x_usb_power: Init work before enabling IRQs power: supply: smb347-charger: Fix interrupt usage if interrupt is unavailable regulator: core: Avoid debugfs: Directory ... already present! error isofs: release buffer head before return watchdog: intel-mid_wdt: Postpone IRQ handler registration till SCU is ready auxdisplay: ht16k33: Fix refresh rate handling objtool: Fix error handling for STD/CLD warnings objtool: Fix retpoline detection in asm code objtool: Fix ".cold" section suffix check for newer versions of GCC scsi: lpfc: Fix ancient double free iommu: Switch gather->end to the inclusive end IB/umad: Return EIO in case of when device disassociated IB/umad: Return EPOLLERR in case of when device disassociated KVM: PPC: Make the VMX instruction emulation routines static powerpc/47x: Disable 256k page size powerpc/time: Enable sched clock for irqtime mmc: owl-mmc: Fix a resource leak in an error handling path and in the remove function mmc: sdhci-sprd: Fix some resource leaks in the remove function mmc: usdhi6rol0: Fix a resource leak in the error handling path of the probe mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes ARM: 9046/1: decompressor: Do not clear SCTLR.nTLSMD for ARMv7+ cores i2c: qcom-geni: Store DMA mapping data in geni_i2c_dev struct amba: Fix resource leak for drivers without .remove iommu: Move iotlb_sync_map out from __iommu_map iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping IB/mlx5: Return appropriate error code instead of ENOMEM IB/cm: Avoid a loop when device has 255 ports tracepoint: Do not fail unregistering a probe due to memory failure rtc: zynqmp: depend on HAS_IOMEM perf tools: Fix DSO filtering when not finding a map for a sampled address perf vendor events arm64: Fix Ampere eMag event typo RDMA/rxe: Fix coding error in rxe_recv.c RDMA/rxe: Fix coding error in rxe_rcv_mcast_pkt RDMA/rxe: Correct skb on loopback path spi: stm32: properly handle 0 byte transfer mfd: altera-sysmgr: Fix physical address storing more mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq() powerpc/pseries/dlpar: handle ibm, configure-connector delay status powerpc/8xx: Fix software emulation interrupt clk: qcom: gcc-msm8998: Fix Alpha PLL type for all GPLLs kunit: tool: fix unit test cleanup handling kselftests: dmabuf-heaps: Fix Makefile's inclusion of the kernel's usr/include dir RDMA/hns: Fixed wrong judgments in the goto branch RDMA/siw: Fix calculation of tx_valid_cpus size RDMA/hns: Fix type of sq_signal_bits RDMA/hns: Disable RQ inline by default clk: divider: fix initialization with parent_hw spi: pxa2xx: Fix the controller numbering for Wildcat Point powerpc/uaccess: Avoid might_fault() when user access is enabled powerpc/kuap: Restore AMR after replaying soft interrupts regulator: qcom-rpmh: fix pm8009 ldo7 clk: aspeed: Fix APLL calculate formula from ast2600-A2 selftests/ftrace: Update synthetic event syntax errors perf symbols: Use (long) for iterator for bfd symbols regulator: bd718x7, bd71828, Fix dvs voltage levels spi: dw: Avoid stack content exposure spi: Skip zero-length transfers in spi_transfer_one_message() printk: avoid prb_first_valid_seq() where possible perf symbols: Fix return value when loading PE DSO nfsd: register pernet ops last, unregister first svcrdma: Hold private mutex while invoking rdma_accept() ceph: fix flush_snap logic after putting caps RDMA/hns: Fixes missing error code of CMDQ RDMA/ucma: Fix use-after-free bug in ucma_create_uevent RDMA/rtrs-srv: Fix stack-out-of-bounds RDMA/rtrs: Only allow addition of path to an already established session RDMA/rtrs-srv: fix memory leak by missing kobject free RDMA/rtrs-srv-sysfs: fix missing put_device RDMA/rtrs-srv: Do not pass a valid pointer to PTR_ERR() Input: sur40 - fix an error code in sur40_probe() perf record: Fix continue profiling after draining the buffer perf intel-pt: Fix missing CYC processing in PSB perf intel-pt: Fix premature IPC perf intel-pt: Fix IPC with CYC threshold perf test: Fix unaligned access in sample parsing test Input: elo - fix an error code in elo_connect() sparc64: only select COMPAT_BINFMT_ELF if BINFMT_ELF is set sparc: fix led.c driver when PROC_FS is not enabled Input: zinitix - fix return type of zinitix_init_touch() ARM: 9065/1: OABI compat: fix build when EPOLL is not enabled misc: eeprom_93xx46: Fix module alias to enable module autoprobe phy: rockchip-emmc: emmc_phy_init() always return 0 phy: cadence-torrent: Fix error code in cdns_torrent_phy_probe() misc: eeprom_93xx46: Add module alias to avoid breaking support for non device tree users PCI: rcar: Always allocate MSI addresses in 32bit space soundwire: cadence: fix ACK/NAK handling pwm: rockchip: Enable APB clock during register access while probing pwm: rockchip: rockchip_pwm_probe(): Remove superfluous clk_unprepare() pwm: rockchip: Eliminate potential race condition when probing PCI: xilinx-cpm: Fix reference count leak on error path VMCI: Use set_page_dirty_lock() when unregistering guest memory PCI: Align checking of syscall user config accessors mei: hbm: call mei_set_devstate() on hbm stop response drm/msm: Fix MSM_INFO_GET_IOVA with carveout drm/msm/dsi: Correct io_start for MSM8994 (20nm PHY) drm/msm/mdp5: Fix wait-for-commit for cmd panels drm/msm: Fix race of GPU init vs timestamp power management. drm/msm: Fix races managing the OOB state for timestamp vs timestamps. drm/msm/dp: trigger unplug event in msm_dp_display_disable vfio/iommu_type1: Populate full dirty when detach non-pinned group vfio/iommu_type1: Fix some sanity checks in detach group vfio-pci/zdev: fix possible segmentation fault issue ext4: fix potential htree index checksum corruption phy: USB_LGM_PHY should depend on X86 coresight: etm4x: Skip accessing TRCPDCR in save/restore nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of() nvmem: core: skip child nodes not matching binding soundwire: bus: use sdw_update_no_pm when initializing a device soundwire: bus: use sdw_write_no_pm when setting the bus scale registers soundwire: export sdw_write/read_no_pm functions soundwire: bus: fix confusion on device used by pm_runtime misc: fastrpc: fix incorrect usage of dma_map_sgtable remoteproc/mediatek: acknowledge watchdog IRQ after handled regmap: sdw: use _no_pm functions in regmap_read/write ext: EXT4_KUNIT_TESTS should depend on EXT4_FS instead of selecting it mailbox: sprd: correct definition of SPRD_OUTBOX_FIFO_FULL device-dax: Fix default return code of range_parse() PCI: pci-bridge-emul: Fix array overruns, improve safety PCI: cadence: Fix DMA range mapping early return error i40e: Fix flow for IPv6 next header (extension header) i40e: Add zero-initialization of AQ command structures i40e: Fix overwriting flow control settings during driver loading i40e: Fix addition of RX filters after enabling FW LLDP agent i40e: Fix VFs not created Take mmap lock in cacheflush syscall nios2: fixed broken sys_clone syscall i40e: Fix add TC filter for IPv6 octeontx2-af: Fix an off by one in rvu_dbg_qsize_write() pwm: iqs620a: Fix overflow and optimize calculations vfio/type1: Use follow_pte() ice: report correct max number of TCs ice: Account for port VLAN in VF max packet size calculation ice: Fix state bits on LLDP mode switch ice: update the number of available RSS queues net: stmmac: fix CBS idleslope and sendslope calculation net/mlx4_core: Add missed mlx4_free_cmd_mailbox() PCI: rockchip: Make 'ep-gpios' DT property optional vxlan: move debug check after netdev unregister wireguard: device: do not generate ICMP for non-IP packets wireguard: kconfig: use arm chacha even with no neon ocfs2: fix a use after free on error mm: memcontrol: fix NR_ANON_THPS accounting in charge moving mm: memcontrol: fix slub memory accounting mm/memory.c: fix potential pte_unmap_unlock pte error mm/hugetlb: fix potential double free in hugetlb_register_node() error path mm/hugetlb: suppress wrong warning info when alloc gigantic page mm/compaction: fix misbehaviors of fast_find_migrateblock() r8169: fix jumbo packet handling on RTL8168e NFSv4: Fixes for nfs4_bitmask_adjust() KVM: SVM: Intercept INVPCID when it's disabled to inject #UD KVM: x86/mmu: Expand collapsible SPTE zap for TDP MMU to ZONE_DEVICE and HugeTLB pages arm64: Add missing ISB after invalidating TLB in __primary_switch i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition i2c: exynos5: Preserve high speed master code mm,thp,shmem: make khugepaged obey tmpfs mount flags mm: fix memory_failure() handling of dax-namespace metadata mm/rmap: fix potential pte_unmap on an not mapped pte proc: use kvzalloc for our kernel buffer csky: Fix a size determination in gpr_get() scsi: bnx2fc: Fix Kconfig warning & CNIC build errors scsi: sd: sd_zbc: Don't pass GFP_NOIO to kvcalloc block: reopen the device in blkdev_reread_part ide/falconide: Fix module unload scsi: sd: Fix Opal support blk-settings: align max_sectors on "logical_block_size" boundary soundwire: intel: fix possible crash when no device is detected ACPI: property: Fix fwnode string properties matching ACPI: configfs: add missing check after configfs_register_default_group() cpufreq: ACPI: Set cpuinfo.max_freq directly if max boost is known HID: logitech-dj: add support for keyboard events in eQUAD step 4 Gaming HID: wacom: Ignore attempts to overwrite the touch_max value from HID Input: raydium_ts_i2c - do not send zero length Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S Input: joydev - prevent potential read overflow in ioctl Input: i8042 - add ASUS Zenbook Flip to noselftest list media: mceusb: Fix potential out-of-bounds shift USB: serial: option: update interface mapping for ZTE P685M usb: musb: Fix runtime PM race in musb_queue_resume_work usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt USB: serial: ftdi_sio: fix FTX sub-integer prescaler USB: serial: pl2303: fix line-speed handling on newer chips USB: serial: mos7840: fix error code in mos7840_write() USB: serial: mos7720: fix error code in mos7720_write() phy: lantiq: rcu-usb2: wait after clock enable ALSA: fireface: fix to parse sync status register of latter protocol ALSA: hda: Add another CometLake-H PCI ID ALSA: hda/hdmi: Drop bogus check at closing a stream ALSA: hda/realtek: modify EAPD in the ALC886 ALSA: hda/realtek: Quirk for HP Spectre x360 14 amp setup MIPS: Ingenic: Disable HPTLB for D0 XBurst CPUs too MIPS: Support binutils configured with --enable-mips-fix-loongson3-llsc=yes MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target=' Revert "MIPS: Octeon: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y" Revert "bcache: Kill btree_io_wq" bcache: Give btree_io_wq correct semantics again bcache: Move journal work to new flush wq Revert "drm/amd/display: Update NV1x SR latency values" drm/amd/display: Add FPU wrappers to dcn21_validate_bandwidth() drm/amd/display: Remove Assert from dcn10_get_dig_frontend drm/amd/display: Add vupdate_no_lock interrupts for DCN2.1 drm/amdkfd: Fix recursive lock warnings drm/amdgpu: Set reference clock to 100Mhz on Renoir (v2) drm/nouveau/kms: handle mDP connectors drm/modes: Switch to 64bit maths to avoid integer overflow drm/sched: Cancel and flush all outstanding jobs before finish. drm/panel: kd35t133: allow using non-continuous dsi clock drm/rockchip: Require the YTR modifier for AFBC ASoC: siu: Fix build error by a wrong const prefix selinux: fix inconsistency between inode_getxattr and inode_listsecurity erofs: initialized fields can only be observed after bit is set tpm_tis: Fix check_locality for correct locality acquisition tpm_tis: Clean up locality release KEYS: trusted: Fix incorrect handling of tpm_get_random() KEYS: trusted: Fix migratable=1 failing KEYS: trusted: Reserve TPM for seal and unseal operations btrfs: do not cleanup upper nodes in btrfs_backref_cleanup_node btrfs: do not warn if we can't find the reloc root when looking up backref btrfs: add asserts for deleting backref cache nodes btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root btrfs: fix reloc root leak with 0 ref reloc roots on recovery btrfs: splice remaining dirty_bg's onto the transaction dirty bg list btrfs: handle space_info::total_bytes_pinned inside the delayed ref itself btrfs: account for new extents being deleted in total_bytes_pinned btrfs: fix extent buffer leak on failure to copy root drm/i915/gt: Flush before changing register state drm/i915/gt: Correct surface base address for renderclear crypto: arm64/sha - add missing module aliases crypto: aesni - prevent misaligned buffers on the stack crypto: michael_mic - fix broken misalignment handling crypto: sun4i-ss - checking sg length is not sufficient crypto: sun4i-ss - IV register does not work on A10 and A13 crypto: sun4i-ss - handle BigEndian for cipher crypto: sun4i-ss - initialize need_fallback soc: samsung: exynos-asv: don't defer early on not-supported SoCs soc: samsung: exynos-asv: handle reading revision register error seccomp: Add missing return in non-void function arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL) misc: rtsx: init of rts522a add OCP power off when no card is present drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue pstore: Fix typo in compression option name dts64: mt7622: fix slow sd card access arm64: dts: agilex: fix phy interface bit shift for gmac1 and gmac2 staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c staging: gdm724x: Fix DMA from stack staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table floppy: reintroduce O_NDELAY fix media: i2c: max9286: fix access to unallocated memory media: ir_toy: add another IR Droid device media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt() media: marvell-ccic: power up the device on mclk enable media: smipcie: fix interrupt handling and IR timeout x86/virt: Eat faults on VMXOFF in reboot flows x86/reboot: Force all cpus to exit VMX root if VMX is supported x86/fault: Fix AMD erratum #91 errata fixup for user code x86/entry: Fix instrumentation annotation powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan rcu: Pull deferred rcuog wake up to rcu_eqs_enter() callers rcu/nocb: Perform deferred wake up before last idle's need_resched() check kprobes: Fix to delay the kprobes jump optimization arm64: Extend workaround for erratum 1024718 to all versions of Cortex-A55 iommu/arm-smmu-qcom: Fix mask extraction for bootloader programmed SMRs arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing arm64 module: set plt* section addresses to 0x0 arm64: spectre: Prevent lockdep splat on v4 mitigation enable path riscv: Disable KSAN_SANITIZE for vDSO watchdog: qcom: Remove incorrect usage of QCOM_WDT_ENABLE_IRQ watchdog: mei_wdt: request stop on unregister coresight: etm4x: Handle accesses to TRCSTALLCTLR mtd: spi-nor: sfdp: Fix last erase region marking mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region mtd: spi-nor: core: Fix erase type discovery for overlaid region mtd: spi-nor: core: Add erase size check for erase command initialization mtd: spi-nor: hisi-sfc: Put child node np on error path fs/affs: release old buffer head on error path seq_file: document how per-entry resources are managed. x86: fix seq_file iteration for pat/memtype.c mm: memcontrol: fix swap undercounting in cgroup2 mm: memcontrol: fix get_active_memcg return value hugetlb: fix update_and_free_page contig page struct assumption hugetlb: fix copy_huge_page_from_user contig page struct assumption mm/vmscan: restore zone_reclaim_mode ABI mm, compaction: make fast_isolate_freepages() stay within zone KVM: nSVM: fix running nested guests when npt=0 nvmem: qcom-spmi-sdam: Fix uninitialized pdev pointer module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols mmc: sdhci-esdhc-imx: fix kernel panic when remove module mmc: sdhci-pci-o2micro: Bug fix for SDR104 HW tuning failure powerpc/32: Preserve cr1 in exception prolog stack check to fix build error powerpc/kexec_file: fix FDT size estimation for kdump kernel powerpc/32s: Add missing call to kuep_lock on syscall entry spmi: spmi-pmic-arb: Fix hw_irq overflow mei: fix transfer over dma with extended header mei: me: emmitsburg workstation DID mei: me: add adler lake point S DID mei: me: add adler lake point LP DID gpio: pcf857x: Fix missing first interrupt mfd: gateworks-gsc: Fix interrupt type printk: fix deadlock when kernel panic exfat: fix shift-out-of-bounds in exfat_fill_super() zonefs: Fix file size of zones in full condition kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error cpufreq: qcom-hw: drop devm_xxx() calls from init/exit hooks cpufreq: intel_pstate: Change intel_pstate_get_hwp_max() argument cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available proc: don't allow async path resolution of /proc/thread-self components s390/vtime: fix inline assembly clobber list virtio/s390: implement virtio-ccw revision 2 correctly um: mm: check more comprehensively for stub changes um: defer killing userspace on page table update failures irqchip/loongson-pch-msi: Use bitmap_zalloc() to allocate bitmap f2fs: fix out-of-repair __setattr_copy() f2fs: enforce the immutable flag on open files f2fs: flush data when enabling checkpoint back sparc32: fix a user-triggerable oops in clear_user() spi: fsl: invert spisel_boot signal on MPC8309 spi: spi-synquacer: fix set_cs handling gfs2: fix glock confusion in function signal_our_withdraw gfs2: Don't skip dlm unlock if glock has an lvb gfs2: Lock imbalance on error path in gfs2_recover_one gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end dm: fix deadlock when swapping to encrypted device dm table: fix iterate_devices based device capability checks dm table: fix DAX iterate_devices based device capability checks dm table: fix zoned iterate_devices based device capability checks dm writecache: fix performance degradation in ssd mode dm writecache: return the exact table values that were set dm writecache: fix writing beyond end of underlying device when shrinking dm era: Recover committed writeset after crash dm era: Update in-core bitset after committing the metadata dm era: Verify the data block size hasn't changed dm era: Fix bitset memory leaks dm era: Use correct value size in equality function of writeset tree dm era: Reinitialize bitset cache before digesting a new writeset dm era: only resize metadata in preresume drm/i915: Reject 446-480MHz HDMI clock on GLK kgdb: fix to kill breakpoints on initmem after boot ipv6: silence compilation warning for non-IPV6 builds net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending wireguard: selftests: test multiple parallel streams wireguard: queueing: get rid of per-peer ring buffers net: sched: fix police ext initialization net: qrtr: Fix memory leak in qrtr_tun_open net_sched: fix RTNL deadlock again caused by request_module() ARM: dts: aspeed: Add LCLK to lpc-snoop Linux 5.10.20 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I3fbcecd9413ce212dac68d5cc800c9457feba56a
2078 lines
59 KiB
C
2078 lines
59 KiB
C
/*
|
|
* Copyright © 1997-2003 by The XFree86 Project, Inc.
|
|
* Copyright © 2007 Dave Airlie
|
|
* Copyright © 2007-2008 Intel Corporation
|
|
* Jesse Barnes <jesse.barnes@intel.com>
|
|
* Copyright 2005-2006 Luc Verhaegen
|
|
* Copyright (c) 2001, Andy Ritger aritger@nvidia.com
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* Except as contained in this notice, the name of the copyright holder(s)
|
|
* and author(s) shall not be used in advertising or otherwise to promote
|
|
* the sale, use or other dealings in this Software without prior written
|
|
* authorization from the copyright holder(s) and author(s).
|
|
*/
|
|
|
|
#include <linux/ctype.h>
|
|
#include <linux/list.h>
|
|
#include <linux/list_sort.h>
|
|
#include <linux/export.h>
|
|
|
|
#include <video/of_videomode.h>
|
|
#include <video/videomode.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
|
#include <drm/drm_device.h>
|
|
#include <drm/drm_modes.h>
|
|
#include <drm/drm_print.h>
|
|
|
|
#include "drm_crtc_internal.h"
|
|
|
|
/**
|
|
* drm_mode_debug_printmodeline - print a mode to dmesg
|
|
* @mode: mode to print
|
|
*
|
|
* Describe @mode using DRM_DEBUG.
|
|
*/
|
|
void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
|
|
{
|
|
DRM_DEBUG_KMS("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_debug_printmodeline);
|
|
|
|
/**
|
|
* drm_mode_create - create a new display mode
|
|
* @dev: DRM device
|
|
*
|
|
* Create a new, cleared drm_display_mode with kzalloc, allocate an ID for it
|
|
* and return it.
|
|
*
|
|
* Returns:
|
|
* Pointer to new mode on success, NULL on error.
|
|
*/
|
|
struct drm_display_mode *drm_mode_create(struct drm_device *dev)
|
|
{
|
|
struct drm_display_mode *nmode;
|
|
|
|
nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL);
|
|
if (!nmode)
|
|
return NULL;
|
|
|
|
return nmode;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_create);
|
|
|
|
/**
|
|
* drm_mode_destroy - remove a mode
|
|
* @dev: DRM device
|
|
* @mode: mode to remove
|
|
*
|
|
* Release @mode's unique ID, then free it @mode structure itself using kfree.
|
|
*/
|
|
void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
|
|
{
|
|
if (!mode)
|
|
return;
|
|
|
|
kfree(mode);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_destroy);
|
|
|
|
/**
|
|
* drm_mode_probed_add - add a mode to a connector's probed_mode list
|
|
* @connector: connector the new mode
|
|
* @mode: mode data
|
|
*
|
|
* Add @mode to @connector's probed_mode list for later use. This list should
|
|
* then in a second step get filtered and all the modes actually supported by
|
|
* the hardware moved to the @connector's modes list.
|
|
*/
|
|
void drm_mode_probed_add(struct drm_connector *connector,
|
|
struct drm_display_mode *mode)
|
|
{
|
|
WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex));
|
|
|
|
list_add_tail(&mode->head, &connector->probed_modes);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_probed_add);
|
|
|
|
/**
|
|
* drm_cvt_mode -create a modeline based on the CVT algorithm
|
|
* @dev: drm device
|
|
* @hdisplay: hdisplay size
|
|
* @vdisplay: vdisplay size
|
|
* @vrefresh: vrefresh rate
|
|
* @reduced: whether to use reduced blanking
|
|
* @interlaced: whether to compute an interlaced mode
|
|
* @margins: whether to add margins (borders)
|
|
*
|
|
* This function is called to generate the modeline based on CVT algorithm
|
|
* according to the hdisplay, vdisplay, vrefresh.
|
|
* It is based from the VESA(TM) Coordinated Video Timing Generator by
|
|
* Graham Loveridge April 9, 2003 available at
|
|
* http://www.elo.utfsm.cl/~elo212/docs/CVTd6r1.xls
|
|
*
|
|
* And it is copied from xf86CVTmode in xserver/hw/xfree86/modes/xf86cvt.c.
|
|
* What I have done is to translate it by using integer calculation.
|
|
*
|
|
* Returns:
|
|
* The modeline based on the CVT algorithm stored in a drm_display_mode object.
|
|
* The display mode object is allocated with drm_mode_create(). Returns NULL
|
|
* when no mode could be allocated.
|
|
*/
|
|
struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay,
|
|
int vdisplay, int vrefresh,
|
|
bool reduced, bool interlaced, bool margins)
|
|
{
|
|
#define HV_FACTOR 1000
|
|
/* 1) top/bottom margin size (% of height) - default: 1.8, */
|
|
#define CVT_MARGIN_PERCENTAGE 18
|
|
/* 2) character cell horizontal granularity (pixels) - default 8 */
|
|
#define CVT_H_GRANULARITY 8
|
|
/* 3) Minimum vertical porch (lines) - default 3 */
|
|
#define CVT_MIN_V_PORCH 3
|
|
/* 4) Minimum number of vertical back porch lines - default 6 */
|
|
#define CVT_MIN_V_BPORCH 6
|
|
/* Pixel Clock step (kHz) */
|
|
#define CVT_CLOCK_STEP 250
|
|
struct drm_display_mode *drm_mode;
|
|
unsigned int vfieldrate, hperiod;
|
|
int hdisplay_rnd, hmargin, vdisplay_rnd, vmargin, vsync;
|
|
int interlace;
|
|
u64 tmp;
|
|
|
|
if (!hdisplay || !vdisplay)
|
|
return NULL;
|
|
|
|
/* allocate the drm_display_mode structure. If failure, we will
|
|
* return directly
|
|
*/
|
|
drm_mode = drm_mode_create(dev);
|
|
if (!drm_mode)
|
|
return NULL;
|
|
|
|
/* the CVT default refresh rate is 60Hz */
|
|
if (!vrefresh)
|
|
vrefresh = 60;
|
|
|
|
/* the required field fresh rate */
|
|
if (interlaced)
|
|
vfieldrate = vrefresh * 2;
|
|
else
|
|
vfieldrate = vrefresh;
|
|
|
|
/* horizontal pixels */
|
|
hdisplay_rnd = hdisplay - (hdisplay % CVT_H_GRANULARITY);
|
|
|
|
/* determine the left&right borders */
|
|
hmargin = 0;
|
|
if (margins) {
|
|
hmargin = hdisplay_rnd * CVT_MARGIN_PERCENTAGE / 1000;
|
|
hmargin -= hmargin % CVT_H_GRANULARITY;
|
|
}
|
|
/* find the total active pixels */
|
|
drm_mode->hdisplay = hdisplay_rnd + 2 * hmargin;
|
|
|
|
/* find the number of lines per field */
|
|
if (interlaced)
|
|
vdisplay_rnd = vdisplay / 2;
|
|
else
|
|
vdisplay_rnd = vdisplay;
|
|
|
|
/* find the top & bottom borders */
|
|
vmargin = 0;
|
|
if (margins)
|
|
vmargin = vdisplay_rnd * CVT_MARGIN_PERCENTAGE / 1000;
|
|
|
|
drm_mode->vdisplay = vdisplay + 2 * vmargin;
|
|
|
|
/* Interlaced */
|
|
if (interlaced)
|
|
interlace = 1;
|
|
else
|
|
interlace = 0;
|
|
|
|
/* Determine VSync Width from aspect ratio */
|
|
if (!(vdisplay % 3) && ((vdisplay * 4 / 3) == hdisplay))
|
|
vsync = 4;
|
|
else if (!(vdisplay % 9) && ((vdisplay * 16 / 9) == hdisplay))
|
|
vsync = 5;
|
|
else if (!(vdisplay % 10) && ((vdisplay * 16 / 10) == hdisplay))
|
|
vsync = 6;
|
|
else if (!(vdisplay % 4) && ((vdisplay * 5 / 4) == hdisplay))
|
|
vsync = 7;
|
|
else if (!(vdisplay % 9) && ((vdisplay * 15 / 9) == hdisplay))
|
|
vsync = 7;
|
|
else /* custom */
|
|
vsync = 10;
|
|
|
|
if (!reduced) {
|
|
/* simplify the GTF calculation */
|
|
/* 4) Minimum time of vertical sync + back porch interval (µs)
|
|
* default 550.0
|
|
*/
|
|
int tmp1, tmp2;
|
|
#define CVT_MIN_VSYNC_BP 550
|
|
/* 3) Nominal HSync width (% of line period) - default 8 */
|
|
#define CVT_HSYNC_PERCENTAGE 8
|
|
unsigned int hblank_percentage;
|
|
int vsyncandback_porch, __maybe_unused vback_porch, hblank;
|
|
|
|
/* estimated the horizontal period */
|
|
tmp1 = HV_FACTOR * 1000000 -
|
|
CVT_MIN_VSYNC_BP * HV_FACTOR * vfieldrate;
|
|
tmp2 = (vdisplay_rnd + 2 * vmargin + CVT_MIN_V_PORCH) * 2 +
|
|
interlace;
|
|
hperiod = tmp1 * 2 / (tmp2 * vfieldrate);
|
|
|
|
tmp1 = CVT_MIN_VSYNC_BP * HV_FACTOR / hperiod + 1;
|
|
/* 9. Find number of lines in sync + backporch */
|
|
if (tmp1 < (vsync + CVT_MIN_V_PORCH))
|
|
vsyncandback_porch = vsync + CVT_MIN_V_PORCH;
|
|
else
|
|
vsyncandback_porch = tmp1;
|
|
/* 10. Find number of lines in back porch */
|
|
vback_porch = vsyncandback_porch - vsync;
|
|
drm_mode->vtotal = vdisplay_rnd + 2 * vmargin +
|
|
vsyncandback_porch + CVT_MIN_V_PORCH;
|
|
/* 5) Definition of Horizontal blanking time limitation */
|
|
/* Gradient (%/kHz) - default 600 */
|
|
#define CVT_M_FACTOR 600
|
|
/* Offset (%) - default 40 */
|
|
#define CVT_C_FACTOR 40
|
|
/* Blanking time scaling factor - default 128 */
|
|
#define CVT_K_FACTOR 128
|
|
/* Scaling factor weighting - default 20 */
|
|
#define CVT_J_FACTOR 20
|
|
#define CVT_M_PRIME (CVT_M_FACTOR * CVT_K_FACTOR / 256)
|
|
#define CVT_C_PRIME ((CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
|
|
CVT_J_FACTOR)
|
|
/* 12. Find ideal blanking duty cycle from formula */
|
|
hblank_percentage = CVT_C_PRIME * HV_FACTOR - CVT_M_PRIME *
|
|
hperiod / 1000;
|
|
/* 13. Blanking time */
|
|
if (hblank_percentage < 20 * HV_FACTOR)
|
|
hblank_percentage = 20 * HV_FACTOR;
|
|
hblank = drm_mode->hdisplay * hblank_percentage /
|
|
(100 * HV_FACTOR - hblank_percentage);
|
|
hblank -= hblank % (2 * CVT_H_GRANULARITY);
|
|
/* 14. find the total pixels per line */
|
|
drm_mode->htotal = drm_mode->hdisplay + hblank;
|
|
drm_mode->hsync_end = drm_mode->hdisplay + hblank / 2;
|
|
drm_mode->hsync_start = drm_mode->hsync_end -
|
|
(drm_mode->htotal * CVT_HSYNC_PERCENTAGE) / 100;
|
|
drm_mode->hsync_start += CVT_H_GRANULARITY -
|
|
drm_mode->hsync_start % CVT_H_GRANULARITY;
|
|
/* fill the Vsync values */
|
|
drm_mode->vsync_start = drm_mode->vdisplay + CVT_MIN_V_PORCH;
|
|
drm_mode->vsync_end = drm_mode->vsync_start + vsync;
|
|
} else {
|
|
/* Reduced blanking */
|
|
/* Minimum vertical blanking interval time (µs)- default 460 */
|
|
#define CVT_RB_MIN_VBLANK 460
|
|
/* Fixed number of clocks for horizontal sync */
|
|
#define CVT_RB_H_SYNC 32
|
|
/* Fixed number of clocks for horizontal blanking */
|
|
#define CVT_RB_H_BLANK 160
|
|
/* Fixed number of lines for vertical front porch - default 3*/
|
|
#define CVT_RB_VFPORCH 3
|
|
int vbilines;
|
|
int tmp1, tmp2;
|
|
/* 8. Estimate Horizontal period. */
|
|
tmp1 = HV_FACTOR * 1000000 -
|
|
CVT_RB_MIN_VBLANK * HV_FACTOR * vfieldrate;
|
|
tmp2 = vdisplay_rnd + 2 * vmargin;
|
|
hperiod = tmp1 / (tmp2 * vfieldrate);
|
|
/* 9. Find number of lines in vertical blanking */
|
|
vbilines = CVT_RB_MIN_VBLANK * HV_FACTOR / hperiod + 1;
|
|
/* 10. Check if vertical blanking is sufficient */
|
|
if (vbilines < (CVT_RB_VFPORCH + vsync + CVT_MIN_V_BPORCH))
|
|
vbilines = CVT_RB_VFPORCH + vsync + CVT_MIN_V_BPORCH;
|
|
/* 11. Find total number of lines in vertical field */
|
|
drm_mode->vtotal = vdisplay_rnd + 2 * vmargin + vbilines;
|
|
/* 12. Find total number of pixels in a line */
|
|
drm_mode->htotal = drm_mode->hdisplay + CVT_RB_H_BLANK;
|
|
/* Fill in HSync values */
|
|
drm_mode->hsync_end = drm_mode->hdisplay + CVT_RB_H_BLANK / 2;
|
|
drm_mode->hsync_start = drm_mode->hsync_end - CVT_RB_H_SYNC;
|
|
/* Fill in VSync values */
|
|
drm_mode->vsync_start = drm_mode->vdisplay + CVT_RB_VFPORCH;
|
|
drm_mode->vsync_end = drm_mode->vsync_start + vsync;
|
|
}
|
|
/* 15/13. Find pixel clock frequency (kHz for xf86) */
|
|
tmp = drm_mode->htotal; /* perform intermediate calcs in u64 */
|
|
tmp *= HV_FACTOR * 1000;
|
|
do_div(tmp, hperiod);
|
|
tmp -= drm_mode->clock % CVT_CLOCK_STEP;
|
|
drm_mode->clock = tmp;
|
|
/* 18/16. Find actual vertical frame frequency */
|
|
/* ignore - just set the mode flag for interlaced */
|
|
if (interlaced) {
|
|
drm_mode->vtotal *= 2;
|
|
drm_mode->flags |= DRM_MODE_FLAG_INTERLACE;
|
|
}
|
|
/* Fill the mode line name */
|
|
drm_mode_set_name(drm_mode);
|
|
if (reduced)
|
|
drm_mode->flags |= (DRM_MODE_FLAG_PHSYNC |
|
|
DRM_MODE_FLAG_NVSYNC);
|
|
else
|
|
drm_mode->flags |= (DRM_MODE_FLAG_PVSYNC |
|
|
DRM_MODE_FLAG_NHSYNC);
|
|
|
|
return drm_mode;
|
|
}
|
|
EXPORT_SYMBOL(drm_cvt_mode);
|
|
|
|
/**
|
|
* drm_gtf_mode_complex - create the modeline based on the full GTF algorithm
|
|
* @dev: drm device
|
|
* @hdisplay: hdisplay size
|
|
* @vdisplay: vdisplay size
|
|
* @vrefresh: vrefresh rate.
|
|
* @interlaced: whether to compute an interlaced mode
|
|
* @margins: desired margin (borders) size
|
|
* @GTF_M: extended GTF formula parameters
|
|
* @GTF_2C: extended GTF formula parameters
|
|
* @GTF_K: extended GTF formula parameters
|
|
* @GTF_2J: extended GTF formula parameters
|
|
*
|
|
* GTF feature blocks specify C and J in multiples of 0.5, so we pass them
|
|
* in here multiplied by two. For a C of 40, pass in 80.
|
|
*
|
|
* Returns:
|
|
* The modeline based on the full GTF algorithm stored in a drm_display_mode object.
|
|
* The display mode object is allocated with drm_mode_create(). Returns NULL
|
|
* when no mode could be allocated.
|
|
*/
|
|
struct drm_display_mode *
|
|
drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay,
|
|
int vrefresh, bool interlaced, int margins,
|
|
int GTF_M, int GTF_2C, int GTF_K, int GTF_2J)
|
|
{ /* 1) top/bottom margin size (% of height) - default: 1.8, */
|
|
#define GTF_MARGIN_PERCENTAGE 18
|
|
/* 2) character cell horizontal granularity (pixels) - default 8 */
|
|
#define GTF_CELL_GRAN 8
|
|
/* 3) Minimum vertical porch (lines) - default 3 */
|
|
#define GTF_MIN_V_PORCH 1
|
|
/* width of vsync in lines */
|
|
#define V_SYNC_RQD 3
|
|
/* width of hsync as % of total line */
|
|
#define H_SYNC_PERCENT 8
|
|
/* min time of vsync + back porch (microsec) */
|
|
#define MIN_VSYNC_PLUS_BP 550
|
|
/* C' and M' are part of the Blanking Duty Cycle computation */
|
|
#define GTF_C_PRIME ((((GTF_2C - GTF_2J) * GTF_K / 256) + GTF_2J) / 2)
|
|
#define GTF_M_PRIME (GTF_K * GTF_M / 256)
|
|
struct drm_display_mode *drm_mode;
|
|
unsigned int hdisplay_rnd, vdisplay_rnd, vfieldrate_rqd;
|
|
int top_margin, bottom_margin;
|
|
int interlace;
|
|
unsigned int hfreq_est;
|
|
int vsync_plus_bp, __maybe_unused vback_porch;
|
|
unsigned int vtotal_lines, __maybe_unused vfieldrate_est;
|
|
unsigned int __maybe_unused hperiod;
|
|
unsigned int vfield_rate, __maybe_unused vframe_rate;
|
|
int left_margin, right_margin;
|
|
unsigned int total_active_pixels, ideal_duty_cycle;
|
|
unsigned int hblank, total_pixels, pixel_freq;
|
|
int hsync, hfront_porch, vodd_front_porch_lines;
|
|
unsigned int tmp1, tmp2;
|
|
|
|
if (!hdisplay || !vdisplay)
|
|
return NULL;
|
|
|
|
drm_mode = drm_mode_create(dev);
|
|
if (!drm_mode)
|
|
return NULL;
|
|
|
|
/* 1. In order to give correct results, the number of horizontal
|
|
* pixels requested is first processed to ensure that it is divisible
|
|
* by the character size, by rounding it to the nearest character
|
|
* cell boundary:
|
|
*/
|
|
hdisplay_rnd = (hdisplay + GTF_CELL_GRAN / 2) / GTF_CELL_GRAN;
|
|
hdisplay_rnd = hdisplay_rnd * GTF_CELL_GRAN;
|
|
|
|
/* 2. If interlace is requested, the number of vertical lines assumed
|
|
* by the calculation must be halved, as the computation calculates
|
|
* the number of vertical lines per field.
|
|
*/
|
|
if (interlaced)
|
|
vdisplay_rnd = vdisplay / 2;
|
|
else
|
|
vdisplay_rnd = vdisplay;
|
|
|
|
/* 3. Find the frame rate required: */
|
|
if (interlaced)
|
|
vfieldrate_rqd = vrefresh * 2;
|
|
else
|
|
vfieldrate_rqd = vrefresh;
|
|
|
|
/* 4. Find number of lines in Top margin: */
|
|
top_margin = 0;
|
|
if (margins)
|
|
top_margin = (vdisplay_rnd * GTF_MARGIN_PERCENTAGE + 500) /
|
|
1000;
|
|
/* 5. Find number of lines in bottom margin: */
|
|
bottom_margin = top_margin;
|
|
|
|
/* 6. If interlace is required, then set variable interlace: */
|
|
if (interlaced)
|
|
interlace = 1;
|
|
else
|
|
interlace = 0;
|
|
|
|
/* 7. Estimate the Horizontal frequency */
|
|
{
|
|
tmp1 = (1000000 - MIN_VSYNC_PLUS_BP * vfieldrate_rqd) / 500;
|
|
tmp2 = (vdisplay_rnd + 2 * top_margin + GTF_MIN_V_PORCH) *
|
|
2 + interlace;
|
|
hfreq_est = (tmp2 * 1000 * vfieldrate_rqd) / tmp1;
|
|
}
|
|
|
|
/* 8. Find the number of lines in V sync + back porch */
|
|
/* [V SYNC+BP] = RINT(([MIN VSYNC+BP] * hfreq_est / 1000000)) */
|
|
vsync_plus_bp = MIN_VSYNC_PLUS_BP * hfreq_est / 1000;
|
|
vsync_plus_bp = (vsync_plus_bp + 500) / 1000;
|
|
/* 9. Find the number of lines in V back porch alone: */
|
|
vback_porch = vsync_plus_bp - V_SYNC_RQD;
|
|
/* 10. Find the total number of lines in Vertical field period: */
|
|
vtotal_lines = vdisplay_rnd + top_margin + bottom_margin +
|
|
vsync_plus_bp + GTF_MIN_V_PORCH;
|
|
/* 11. Estimate the Vertical field frequency: */
|
|
vfieldrate_est = hfreq_est / vtotal_lines;
|
|
/* 12. Find the actual horizontal period: */
|
|
hperiod = 1000000 / (vfieldrate_rqd * vtotal_lines);
|
|
|
|
/* 13. Find the actual Vertical field frequency: */
|
|
vfield_rate = hfreq_est / vtotal_lines;
|
|
/* 14. Find the Vertical frame frequency: */
|
|
if (interlaced)
|
|
vframe_rate = vfield_rate / 2;
|
|
else
|
|
vframe_rate = vfield_rate;
|
|
/* 15. Find number of pixels in left margin: */
|
|
if (margins)
|
|
left_margin = (hdisplay_rnd * GTF_MARGIN_PERCENTAGE + 500) /
|
|
1000;
|
|
else
|
|
left_margin = 0;
|
|
|
|
/* 16.Find number of pixels in right margin: */
|
|
right_margin = left_margin;
|
|
/* 17.Find total number of active pixels in image and left and right */
|
|
total_active_pixels = hdisplay_rnd + left_margin + right_margin;
|
|
/* 18.Find the ideal blanking duty cycle from blanking duty cycle */
|
|
ideal_duty_cycle = GTF_C_PRIME * 1000 -
|
|
(GTF_M_PRIME * 1000000 / hfreq_est);
|
|
/* 19.Find the number of pixels in the blanking time to the nearest
|
|
* double character cell: */
|
|
hblank = total_active_pixels * ideal_duty_cycle /
|
|
(100000 - ideal_duty_cycle);
|
|
hblank = (hblank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN);
|
|
hblank = hblank * 2 * GTF_CELL_GRAN;
|
|
/* 20.Find total number of pixels: */
|
|
total_pixels = total_active_pixels + hblank;
|
|
/* 21.Find pixel clock frequency: */
|
|
pixel_freq = total_pixels * hfreq_est / 1000;
|
|
/* Stage 1 computations are now complete; I should really pass
|
|
* the results to another function and do the Stage 2 computations,
|
|
* but I only need a few more values so I'll just append the
|
|
* computations here for now */
|
|
/* 17. Find the number of pixels in the horizontal sync period: */
|
|
hsync = H_SYNC_PERCENT * total_pixels / 100;
|
|
hsync = (hsync + GTF_CELL_GRAN / 2) / GTF_CELL_GRAN;
|
|
hsync = hsync * GTF_CELL_GRAN;
|
|
/* 18. Find the number of pixels in horizontal front porch period */
|
|
hfront_porch = hblank / 2 - hsync;
|
|
/* 36. Find the number of lines in the odd front porch period: */
|
|
vodd_front_porch_lines = GTF_MIN_V_PORCH ;
|
|
|
|
/* finally, pack the results in the mode struct */
|
|
drm_mode->hdisplay = hdisplay_rnd;
|
|
drm_mode->hsync_start = hdisplay_rnd + hfront_porch;
|
|
drm_mode->hsync_end = drm_mode->hsync_start + hsync;
|
|
drm_mode->htotal = total_pixels;
|
|
drm_mode->vdisplay = vdisplay_rnd;
|
|
drm_mode->vsync_start = vdisplay_rnd + vodd_front_porch_lines;
|
|
drm_mode->vsync_end = drm_mode->vsync_start + V_SYNC_RQD;
|
|
drm_mode->vtotal = vtotal_lines;
|
|
|
|
drm_mode->clock = pixel_freq;
|
|
|
|
if (interlaced) {
|
|
drm_mode->vtotal *= 2;
|
|
drm_mode->flags |= DRM_MODE_FLAG_INTERLACE;
|
|
}
|
|
|
|
drm_mode_set_name(drm_mode);
|
|
if (GTF_M == 600 && GTF_2C == 80 && GTF_K == 128 && GTF_2J == 40)
|
|
drm_mode->flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC;
|
|
else
|
|
drm_mode->flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
|
|
|
|
return drm_mode;
|
|
}
|
|
EXPORT_SYMBOL(drm_gtf_mode_complex);
|
|
|
|
/**
|
|
* drm_gtf_mode - create the modeline based on the GTF algorithm
|
|
* @dev: drm device
|
|
* @hdisplay: hdisplay size
|
|
* @vdisplay: vdisplay size
|
|
* @vrefresh: vrefresh rate.
|
|
* @interlaced: whether to compute an interlaced mode
|
|
* @margins: desired margin (borders) size
|
|
*
|
|
* return the modeline based on GTF algorithm
|
|
*
|
|
* This function is to create the modeline based on the GTF algorithm.
|
|
* Generalized Timing Formula is derived from:
|
|
*
|
|
* GTF Spreadsheet by Andy Morrish (1/5/97)
|
|
* available at https://www.vesa.org
|
|
*
|
|
* And it is copied from the file of xserver/hw/xfree86/modes/xf86gtf.c.
|
|
* What I have done is to translate it by using integer calculation.
|
|
* I also refer to the function of fb_get_mode in the file of
|
|
* drivers/video/fbmon.c
|
|
*
|
|
* Standard GTF parameters::
|
|
*
|
|
* M = 600
|
|
* C = 40
|
|
* K = 128
|
|
* J = 20
|
|
*
|
|
* Returns:
|
|
* The modeline based on the GTF algorithm stored in a drm_display_mode object.
|
|
* The display mode object is allocated with drm_mode_create(). Returns NULL
|
|
* when no mode could be allocated.
|
|
*/
|
|
struct drm_display_mode *
|
|
drm_gtf_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh,
|
|
bool interlaced, int margins)
|
|
{
|
|
return drm_gtf_mode_complex(dev, hdisplay, vdisplay, vrefresh,
|
|
interlaced, margins,
|
|
600, 40 * 2, 128, 20 * 2);
|
|
}
|
|
EXPORT_SYMBOL(drm_gtf_mode);
|
|
|
|
#ifdef CONFIG_VIDEOMODE_HELPERS
|
|
/**
|
|
* drm_display_mode_from_videomode - fill in @dmode using @vm,
|
|
* @vm: videomode structure to use as source
|
|
* @dmode: drm_display_mode structure to use as destination
|
|
*
|
|
* Fills out @dmode using the display mode specified in @vm.
|
|
*/
|
|
void drm_display_mode_from_videomode(const struct videomode *vm,
|
|
struct drm_display_mode *dmode)
|
|
{
|
|
dmode->hdisplay = vm->hactive;
|
|
dmode->hsync_start = dmode->hdisplay + vm->hfront_porch;
|
|
dmode->hsync_end = dmode->hsync_start + vm->hsync_len;
|
|
dmode->htotal = dmode->hsync_end + vm->hback_porch;
|
|
|
|
dmode->vdisplay = vm->vactive;
|
|
dmode->vsync_start = dmode->vdisplay + vm->vfront_porch;
|
|
dmode->vsync_end = dmode->vsync_start + vm->vsync_len;
|
|
dmode->vtotal = dmode->vsync_end + vm->vback_porch;
|
|
|
|
dmode->clock = vm->pixelclock / 1000;
|
|
|
|
dmode->flags = 0;
|
|
if (vm->flags & DISPLAY_FLAGS_HSYNC_HIGH)
|
|
dmode->flags |= DRM_MODE_FLAG_PHSYNC;
|
|
else if (vm->flags & DISPLAY_FLAGS_HSYNC_LOW)
|
|
dmode->flags |= DRM_MODE_FLAG_NHSYNC;
|
|
if (vm->flags & DISPLAY_FLAGS_VSYNC_HIGH)
|
|
dmode->flags |= DRM_MODE_FLAG_PVSYNC;
|
|
else if (vm->flags & DISPLAY_FLAGS_VSYNC_LOW)
|
|
dmode->flags |= DRM_MODE_FLAG_NVSYNC;
|
|
if (vm->flags & DISPLAY_FLAGS_INTERLACED)
|
|
dmode->flags |= DRM_MODE_FLAG_INTERLACE;
|
|
if (vm->flags & DISPLAY_FLAGS_DOUBLESCAN)
|
|
dmode->flags |= DRM_MODE_FLAG_DBLSCAN;
|
|
if (vm->flags & DISPLAY_FLAGS_DOUBLECLK)
|
|
dmode->flags |= DRM_MODE_FLAG_DBLCLK;
|
|
drm_mode_set_name(dmode);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_display_mode_from_videomode);
|
|
|
|
/**
|
|
* drm_display_mode_to_videomode - fill in @vm using @dmode,
|
|
* @dmode: drm_display_mode structure to use as source
|
|
* @vm: videomode structure to use as destination
|
|
*
|
|
* Fills out @vm using the display mode specified in @dmode.
|
|
*/
|
|
void drm_display_mode_to_videomode(const struct drm_display_mode *dmode,
|
|
struct videomode *vm)
|
|
{
|
|
vm->hactive = dmode->hdisplay;
|
|
vm->hfront_porch = dmode->hsync_start - dmode->hdisplay;
|
|
vm->hsync_len = dmode->hsync_end - dmode->hsync_start;
|
|
vm->hback_porch = dmode->htotal - dmode->hsync_end;
|
|
|
|
vm->vactive = dmode->vdisplay;
|
|
vm->vfront_porch = dmode->vsync_start - dmode->vdisplay;
|
|
vm->vsync_len = dmode->vsync_end - dmode->vsync_start;
|
|
vm->vback_porch = dmode->vtotal - dmode->vsync_end;
|
|
|
|
vm->pixelclock = dmode->clock * 1000;
|
|
|
|
vm->flags = 0;
|
|
if (dmode->flags & DRM_MODE_FLAG_PHSYNC)
|
|
vm->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
|
|
else if (dmode->flags & DRM_MODE_FLAG_NHSYNC)
|
|
vm->flags |= DISPLAY_FLAGS_HSYNC_LOW;
|
|
if (dmode->flags & DRM_MODE_FLAG_PVSYNC)
|
|
vm->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
|
|
else if (dmode->flags & DRM_MODE_FLAG_NVSYNC)
|
|
vm->flags |= DISPLAY_FLAGS_VSYNC_LOW;
|
|
if (dmode->flags & DRM_MODE_FLAG_INTERLACE)
|
|
vm->flags |= DISPLAY_FLAGS_INTERLACED;
|
|
if (dmode->flags & DRM_MODE_FLAG_DBLSCAN)
|
|
vm->flags |= DISPLAY_FLAGS_DOUBLESCAN;
|
|
if (dmode->flags & DRM_MODE_FLAG_DBLCLK)
|
|
vm->flags |= DISPLAY_FLAGS_DOUBLECLK;
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_display_mode_to_videomode);
|
|
|
|
/**
|
|
* drm_bus_flags_from_videomode - extract information about pixelclk and
|
|
* DE polarity from videomode and store it in a separate variable
|
|
* @vm: videomode structure to use
|
|
* @bus_flags: information about pixelclk, sync and DE polarity will be stored
|
|
* here
|
|
*
|
|
* Sets DRM_BUS_FLAG_DE_(LOW|HIGH), DRM_BUS_FLAG_PIXDATA_DRIVE_(POS|NEG)EDGE
|
|
* and DISPLAY_FLAGS_SYNC_(POS|NEG)EDGE in @bus_flags according to DISPLAY_FLAGS
|
|
* found in @vm
|
|
*/
|
|
void drm_bus_flags_from_videomode(const struct videomode *vm, u32 *bus_flags)
|
|
{
|
|
*bus_flags = 0;
|
|
if (vm->flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
|
|
*bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
|
|
if (vm->flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
|
|
*bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
|
|
|
|
if (vm->flags & DISPLAY_FLAGS_SYNC_POSEDGE)
|
|
*bus_flags |= DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE;
|
|
if (vm->flags & DISPLAY_FLAGS_SYNC_NEGEDGE)
|
|
*bus_flags |= DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE;
|
|
|
|
if (vm->flags & DISPLAY_FLAGS_DE_LOW)
|
|
*bus_flags |= DRM_BUS_FLAG_DE_LOW;
|
|
if (vm->flags & DISPLAY_FLAGS_DE_HIGH)
|
|
*bus_flags |= DRM_BUS_FLAG_DE_HIGH;
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_bus_flags_from_videomode);
|
|
|
|
#ifdef CONFIG_OF
|
|
/**
|
|
* of_get_drm_display_mode - get a drm_display_mode from devicetree
|
|
* @np: device_node with the timing specification
|
|
* @dmode: will be set to the return value
|
|
* @bus_flags: information about pixelclk, sync and DE polarity
|
|
* @index: index into the list of display timings in devicetree
|
|
*
|
|
* This function is expensive and should only be used, if only one mode is to be
|
|
* read from DT. To get multiple modes start with of_get_display_timings and
|
|
* work with that instead.
|
|
*
|
|
* Returns:
|
|
* 0 on success, a negative errno code when no of videomode node was found.
|
|
*/
|
|
int of_get_drm_display_mode(struct device_node *np,
|
|
struct drm_display_mode *dmode, u32 *bus_flags,
|
|
int index)
|
|
{
|
|
struct videomode vm;
|
|
int ret;
|
|
|
|
ret = of_get_videomode(np, &vm, index);
|
|
if (ret)
|
|
return ret;
|
|
|
|
drm_display_mode_from_videomode(&vm, dmode);
|
|
if (bus_flags)
|
|
drm_bus_flags_from_videomode(&vm, bus_flags);
|
|
|
|
pr_debug("%pOF: got %dx%d display mode\n",
|
|
np, vm.hactive, vm.vactive);
|
|
drm_mode_debug_printmodeline(dmode);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(of_get_drm_display_mode);
|
|
#endif /* CONFIG_OF */
|
|
#endif /* CONFIG_VIDEOMODE_HELPERS */
|
|
|
|
/**
|
|
* drm_mode_set_name - set the name on a mode
|
|
* @mode: name will be set in this mode
|
|
*
|
|
* Set the name of @mode to a standard format which is <hdisplay>x<vdisplay>
|
|
* with an optional 'i' suffix for interlaced modes.
|
|
*/
|
|
void drm_mode_set_name(struct drm_display_mode *mode)
|
|
{
|
|
bool interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
|
|
|
|
snprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d%s",
|
|
mode->hdisplay, mode->vdisplay,
|
|
interlaced ? "i" : "");
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_set_name);
|
|
|
|
/**
|
|
* drm_mode_vrefresh - get the vrefresh of a mode
|
|
* @mode: mode
|
|
*
|
|
* Returns:
|
|
* @modes's vrefresh rate in Hz, rounded to the nearest integer. Calculates the
|
|
* value first if it is not yet set.
|
|
*/
|
|
int drm_mode_vrefresh(const struct drm_display_mode *mode)
|
|
{
|
|
unsigned int num, den;
|
|
|
|
if (mode->htotal == 0 || mode->vtotal == 0)
|
|
return 0;
|
|
|
|
num = mode->clock;
|
|
den = mode->htotal * mode->vtotal;
|
|
|
|
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
|
|
num *= 2;
|
|
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
|
|
den *= 2;
|
|
if (mode->vscan > 1)
|
|
den *= mode->vscan;
|
|
|
|
return DIV_ROUND_CLOSEST_ULL(mul_u32_u32(num, 1000), den);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_vrefresh);
|
|
|
|
/**
|
|
* drm_mode_get_hv_timing - Fetches hdisplay/vdisplay for given mode
|
|
* @mode: mode to query
|
|
* @hdisplay: hdisplay value to fill in
|
|
* @vdisplay: vdisplay value to fill in
|
|
*
|
|
* The vdisplay value will be doubled if the specified mode is a stereo mode of
|
|
* the appropriate layout.
|
|
*/
|
|
void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
|
|
int *hdisplay, int *vdisplay)
|
|
{
|
|
struct drm_display_mode adjusted = *mode;
|
|
|
|
drm_mode_set_crtcinfo(&adjusted, CRTC_STEREO_DOUBLE_ONLY);
|
|
*hdisplay = adjusted.crtc_hdisplay;
|
|
*vdisplay = adjusted.crtc_vdisplay;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_get_hv_timing);
|
|
|
|
/**
|
|
* drm_mode_set_crtcinfo - set CRTC modesetting timing parameters
|
|
* @p: mode
|
|
* @adjust_flags: a combination of adjustment flags
|
|
*
|
|
* Setup the CRTC modesetting timing parameters for @p, adjusting if necessary.
|
|
*
|
|
* - The CRTC_INTERLACE_HALVE_V flag can be used to halve vertical timings of
|
|
* interlaced modes.
|
|
* - The CRTC_STEREO_DOUBLE flag can be used to compute the timings for
|
|
* buffers containing two eyes (only adjust the timings when needed, eg. for
|
|
* "frame packing" or "side by side full").
|
|
* - The CRTC_NO_DBLSCAN and CRTC_NO_VSCAN flags request that adjustment *not*
|
|
* be performed for doublescan and vscan > 1 modes respectively.
|
|
*/
|
|
void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
|
|
{
|
|
if (!p)
|
|
return;
|
|
|
|
p->crtc_clock = p->clock;
|
|
p->crtc_hdisplay = p->hdisplay;
|
|
p->crtc_hsync_start = p->hsync_start;
|
|
p->crtc_hsync_end = p->hsync_end;
|
|
p->crtc_htotal = p->htotal;
|
|
p->crtc_hskew = p->hskew;
|
|
p->crtc_vdisplay = p->vdisplay;
|
|
p->crtc_vsync_start = p->vsync_start;
|
|
p->crtc_vsync_end = p->vsync_end;
|
|
p->crtc_vtotal = p->vtotal;
|
|
|
|
if (p->flags & DRM_MODE_FLAG_INTERLACE) {
|
|
if (adjust_flags & CRTC_INTERLACE_HALVE_V) {
|
|
p->crtc_vdisplay /= 2;
|
|
p->crtc_vsync_start /= 2;
|
|
p->crtc_vsync_end /= 2;
|
|
p->crtc_vtotal /= 2;
|
|
}
|
|
}
|
|
|
|
if (!(adjust_flags & CRTC_NO_DBLSCAN)) {
|
|
if (p->flags & DRM_MODE_FLAG_DBLSCAN) {
|
|
p->crtc_vdisplay *= 2;
|
|
p->crtc_vsync_start *= 2;
|
|
p->crtc_vsync_end *= 2;
|
|
p->crtc_vtotal *= 2;
|
|
}
|
|
}
|
|
|
|
if (!(adjust_flags & CRTC_NO_VSCAN)) {
|
|
if (p->vscan > 1) {
|
|
p->crtc_vdisplay *= p->vscan;
|
|
p->crtc_vsync_start *= p->vscan;
|
|
p->crtc_vsync_end *= p->vscan;
|
|
p->crtc_vtotal *= p->vscan;
|
|
}
|
|
}
|
|
|
|
if (adjust_flags & CRTC_STEREO_DOUBLE) {
|
|
unsigned int layout = p->flags & DRM_MODE_FLAG_3D_MASK;
|
|
|
|
switch (layout) {
|
|
case DRM_MODE_FLAG_3D_FRAME_PACKING:
|
|
p->crtc_clock *= 2;
|
|
p->crtc_vdisplay += p->crtc_vtotal;
|
|
p->crtc_vsync_start += p->crtc_vtotal;
|
|
p->crtc_vsync_end += p->crtc_vtotal;
|
|
p->crtc_vtotal += p->crtc_vtotal;
|
|
break;
|
|
}
|
|
}
|
|
|
|
p->crtc_vblank_start = min(p->crtc_vsync_start, p->crtc_vdisplay);
|
|
p->crtc_vblank_end = max(p->crtc_vsync_end, p->crtc_vtotal);
|
|
p->crtc_hblank_start = min(p->crtc_hsync_start, p->crtc_hdisplay);
|
|
p->crtc_hblank_end = max(p->crtc_hsync_end, p->crtc_htotal);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_set_crtcinfo);
|
|
|
|
/**
|
|
* drm_mode_copy - copy the mode
|
|
* @dst: mode to overwrite
|
|
* @src: mode to copy
|
|
*
|
|
* Copy an existing mode into another mode, preserving the object id and
|
|
* list head of the destination mode.
|
|
*/
|
|
void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
|
|
{
|
|
struct list_head head = dst->head;
|
|
|
|
*dst = *src;
|
|
dst->head = head;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_copy);
|
|
|
|
/**
|
|
* drm_mode_duplicate - allocate and duplicate an existing mode
|
|
* @dev: drm_device to allocate the duplicated mode for
|
|
* @mode: mode to duplicate
|
|
*
|
|
* Just allocate a new mode, copy the existing mode into it, and return
|
|
* a pointer to it. Used to create new instances of established modes.
|
|
*
|
|
* Returns:
|
|
* Pointer to duplicated mode on success, NULL on error.
|
|
*/
|
|
struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
|
|
const struct drm_display_mode *mode)
|
|
{
|
|
struct drm_display_mode *nmode;
|
|
|
|
nmode = drm_mode_create(dev);
|
|
if (!nmode)
|
|
return NULL;
|
|
|
|
drm_mode_copy(nmode, mode);
|
|
|
|
return nmode;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_duplicate);
|
|
|
|
static bool drm_mode_match_timings(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return mode1->hdisplay == mode2->hdisplay &&
|
|
mode1->hsync_start == mode2->hsync_start &&
|
|
mode1->hsync_end == mode2->hsync_end &&
|
|
mode1->htotal == mode2->htotal &&
|
|
mode1->hskew == mode2->hskew &&
|
|
mode1->vdisplay == mode2->vdisplay &&
|
|
mode1->vsync_start == mode2->vsync_start &&
|
|
mode1->vsync_end == mode2->vsync_end &&
|
|
mode1->vtotal == mode2->vtotal &&
|
|
mode1->vscan == mode2->vscan;
|
|
}
|
|
|
|
static bool drm_mode_match_clock(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
/*
|
|
* do clock check convert to PICOS
|
|
* so fb modes get matched the same
|
|
*/
|
|
if (mode1->clock && mode2->clock)
|
|
return KHZ2PICOS(mode1->clock) == KHZ2PICOS(mode2->clock);
|
|
else
|
|
return mode1->clock == mode2->clock;
|
|
}
|
|
|
|
static bool drm_mode_match_flags(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
|
|
(mode2->flags & ~DRM_MODE_FLAG_3D_MASK);
|
|
}
|
|
|
|
static bool drm_mode_match_3d_flags(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return (mode1->flags & DRM_MODE_FLAG_3D_MASK) ==
|
|
(mode2->flags & DRM_MODE_FLAG_3D_MASK);
|
|
}
|
|
|
|
static bool drm_mode_match_aspect_ratio(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_match - test modes for (partial) equality
|
|
* @mode1: first mode
|
|
* @mode2: second mode
|
|
* @match_flags: which parts need to match (DRM_MODE_MATCH_*)
|
|
*
|
|
* Check to see if @mode1 and @mode2 are equivalent.
|
|
*
|
|
* Returns:
|
|
* True if the modes are (partially) equal, false otherwise.
|
|
*/
|
|
bool drm_mode_match(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2,
|
|
unsigned int match_flags)
|
|
{
|
|
if (!mode1 && !mode2)
|
|
return true;
|
|
|
|
if (!mode1 || !mode2)
|
|
return false;
|
|
|
|
if (match_flags & DRM_MODE_MATCH_TIMINGS &&
|
|
!drm_mode_match_timings(mode1, mode2))
|
|
return false;
|
|
|
|
if (match_flags & DRM_MODE_MATCH_CLOCK &&
|
|
!drm_mode_match_clock(mode1, mode2))
|
|
return false;
|
|
|
|
if (match_flags & DRM_MODE_MATCH_FLAGS &&
|
|
!drm_mode_match_flags(mode1, mode2))
|
|
return false;
|
|
|
|
if (match_flags & DRM_MODE_MATCH_3D_FLAGS &&
|
|
!drm_mode_match_3d_flags(mode1, mode2))
|
|
return false;
|
|
|
|
if (match_flags & DRM_MODE_MATCH_ASPECT_RATIO &&
|
|
!drm_mode_match_aspect_ratio(mode1, mode2))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_match);
|
|
|
|
/**
|
|
* drm_mode_equal - test modes for equality
|
|
* @mode1: first mode
|
|
* @mode2: second mode
|
|
*
|
|
* Check to see if @mode1 and @mode2 are equivalent.
|
|
*
|
|
* Returns:
|
|
* True if the modes are equal, false otherwise.
|
|
*/
|
|
bool drm_mode_equal(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return drm_mode_match(mode1, mode2,
|
|
DRM_MODE_MATCH_TIMINGS |
|
|
DRM_MODE_MATCH_CLOCK |
|
|
DRM_MODE_MATCH_FLAGS |
|
|
DRM_MODE_MATCH_3D_FLAGS|
|
|
DRM_MODE_MATCH_ASPECT_RATIO);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_equal);
|
|
|
|
/**
|
|
* drm_mode_equal_no_clocks - test modes for equality
|
|
* @mode1: first mode
|
|
* @mode2: second mode
|
|
*
|
|
* Check to see if @mode1 and @mode2 are equivalent, but
|
|
* don't check the pixel clocks.
|
|
*
|
|
* Returns:
|
|
* True if the modes are equal, false otherwise.
|
|
*/
|
|
bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return drm_mode_match(mode1, mode2,
|
|
DRM_MODE_MATCH_TIMINGS |
|
|
DRM_MODE_MATCH_FLAGS |
|
|
DRM_MODE_MATCH_3D_FLAGS);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_equal_no_clocks);
|
|
|
|
/**
|
|
* drm_mode_equal_no_clocks_no_stereo - test modes for equality
|
|
* @mode1: first mode
|
|
* @mode2: second mode
|
|
*
|
|
* Check to see if @mode1 and @mode2 are equivalent, but
|
|
* don't check the pixel clocks nor the stereo layout.
|
|
*
|
|
* Returns:
|
|
* True if the modes are equal, false otherwise.
|
|
*/
|
|
bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
|
|
const struct drm_display_mode *mode2)
|
|
{
|
|
return drm_mode_match(mode1, mode2,
|
|
DRM_MODE_MATCH_TIMINGS |
|
|
DRM_MODE_MATCH_FLAGS);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
|
|
|
|
static enum drm_mode_status
|
|
drm_mode_validate_basic(const struct drm_display_mode *mode)
|
|
{
|
|
if (mode->type & ~DRM_MODE_TYPE_ALL)
|
|
return MODE_BAD;
|
|
|
|
if (mode->flags & ~DRM_MODE_FLAG_ALL)
|
|
return MODE_BAD;
|
|
|
|
if ((mode->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX)
|
|
return MODE_BAD;
|
|
|
|
if (mode->clock == 0)
|
|
return MODE_CLOCK_LOW;
|
|
|
|
if (mode->hdisplay == 0 ||
|
|
mode->hsync_start < mode->hdisplay ||
|
|
mode->hsync_end < mode->hsync_start ||
|
|
mode->htotal < mode->hsync_end)
|
|
return MODE_H_ILLEGAL;
|
|
|
|
if (mode->vdisplay == 0 ||
|
|
mode->vsync_start < mode->vdisplay ||
|
|
mode->vsync_end < mode->vsync_start ||
|
|
mode->vtotal < mode->vsync_end)
|
|
return MODE_V_ILLEGAL;
|
|
|
|
return MODE_OK;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_validate_driver - make sure the mode is somewhat sane
|
|
* @dev: drm device
|
|
* @mode: mode to check
|
|
*
|
|
* First do basic validation on the mode, and then allow the driver
|
|
* to check for device/driver specific limitations via the optional
|
|
* &drm_mode_config_helper_funcs.mode_valid hook.
|
|
*
|
|
* Returns:
|
|
* The mode status
|
|
*/
|
|
enum drm_mode_status
|
|
drm_mode_validate_driver(struct drm_device *dev,
|
|
const struct drm_display_mode *mode)
|
|
{
|
|
enum drm_mode_status status;
|
|
|
|
status = drm_mode_validate_basic(mode);
|
|
if (status != MODE_OK)
|
|
return status;
|
|
|
|
if (dev->mode_config.funcs->mode_valid)
|
|
return dev->mode_config.funcs->mode_valid(dev, mode);
|
|
else
|
|
return MODE_OK;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_validate_driver);
|
|
|
|
/**
|
|
* drm_mode_validate_size - make sure modes adhere to size constraints
|
|
* @mode: mode to check
|
|
* @maxX: maximum width
|
|
* @maxY: maximum height
|
|
*
|
|
* This function is a helper which can be used to validate modes against size
|
|
* limitations of the DRM device/connector. If a mode is too big its status
|
|
* member is updated with the appropriate validation failure code. The list
|
|
* itself is not changed.
|
|
*
|
|
* Returns:
|
|
* The mode status
|
|
*/
|
|
enum drm_mode_status
|
|
drm_mode_validate_size(const struct drm_display_mode *mode,
|
|
int maxX, int maxY)
|
|
{
|
|
if (maxX > 0 && mode->hdisplay > maxX)
|
|
return MODE_VIRTUAL_X;
|
|
|
|
if (maxY > 0 && mode->vdisplay > maxY)
|
|
return MODE_VIRTUAL_Y;
|
|
|
|
return MODE_OK;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_validate_size);
|
|
|
|
/**
|
|
* drm_mode_validate_ycbcr420 - add 'ycbcr420-only' modes only when allowed
|
|
* @mode: mode to check
|
|
* @connector: drm connector under action
|
|
*
|
|
* This function is a helper which can be used to filter out any YCBCR420
|
|
* only mode, when the source doesn't support it.
|
|
*
|
|
* Returns:
|
|
* The mode status
|
|
*/
|
|
enum drm_mode_status
|
|
drm_mode_validate_ycbcr420(const struct drm_display_mode *mode,
|
|
struct drm_connector *connector)
|
|
{
|
|
u8 vic = drm_match_cea_mode(mode);
|
|
enum drm_mode_status status = MODE_OK;
|
|
struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
|
|
|
|
if (test_bit(vic, hdmi->y420_vdb_modes)) {
|
|
if (!connector->ycbcr_420_allowed)
|
|
status = MODE_NO_420;
|
|
}
|
|
|
|
return status;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_validate_ycbcr420);
|
|
|
|
#define MODE_STATUS(status) [MODE_ ## status + 3] = #status
|
|
|
|
static const char * const drm_mode_status_names[] = {
|
|
MODE_STATUS(OK),
|
|
MODE_STATUS(HSYNC),
|
|
MODE_STATUS(VSYNC),
|
|
MODE_STATUS(H_ILLEGAL),
|
|
MODE_STATUS(V_ILLEGAL),
|
|
MODE_STATUS(BAD_WIDTH),
|
|
MODE_STATUS(NOMODE),
|
|
MODE_STATUS(NO_INTERLACE),
|
|
MODE_STATUS(NO_DBLESCAN),
|
|
MODE_STATUS(NO_VSCAN),
|
|
MODE_STATUS(MEM),
|
|
MODE_STATUS(VIRTUAL_X),
|
|
MODE_STATUS(VIRTUAL_Y),
|
|
MODE_STATUS(MEM_VIRT),
|
|
MODE_STATUS(NOCLOCK),
|
|
MODE_STATUS(CLOCK_HIGH),
|
|
MODE_STATUS(CLOCK_LOW),
|
|
MODE_STATUS(CLOCK_RANGE),
|
|
MODE_STATUS(BAD_HVALUE),
|
|
MODE_STATUS(BAD_VVALUE),
|
|
MODE_STATUS(BAD_VSCAN),
|
|
MODE_STATUS(HSYNC_NARROW),
|
|
MODE_STATUS(HSYNC_WIDE),
|
|
MODE_STATUS(HBLANK_NARROW),
|
|
MODE_STATUS(HBLANK_WIDE),
|
|
MODE_STATUS(VSYNC_NARROW),
|
|
MODE_STATUS(VSYNC_WIDE),
|
|
MODE_STATUS(VBLANK_NARROW),
|
|
MODE_STATUS(VBLANK_WIDE),
|
|
MODE_STATUS(PANEL),
|
|
MODE_STATUS(INTERLACE_WIDTH),
|
|
MODE_STATUS(ONE_WIDTH),
|
|
MODE_STATUS(ONE_HEIGHT),
|
|
MODE_STATUS(ONE_SIZE),
|
|
MODE_STATUS(NO_REDUCED),
|
|
MODE_STATUS(NO_STEREO),
|
|
MODE_STATUS(NO_420),
|
|
MODE_STATUS(STALE),
|
|
MODE_STATUS(BAD),
|
|
MODE_STATUS(ERROR),
|
|
};
|
|
|
|
#undef MODE_STATUS
|
|
|
|
const char *drm_get_mode_status_name(enum drm_mode_status status)
|
|
{
|
|
int index = status + 3;
|
|
|
|
if (WARN_ON(index < 0 || index >= ARRAY_SIZE(drm_mode_status_names)))
|
|
return "";
|
|
|
|
return drm_mode_status_names[index];
|
|
}
|
|
|
|
/**
|
|
* drm_mode_prune_invalid - remove invalid modes from mode list
|
|
* @dev: DRM device
|
|
* @mode_list: list of modes to check
|
|
* @verbose: be verbose about it
|
|
*
|
|
* This helper function can be used to prune a display mode list after
|
|
* validation has been completed. All modes whose status is not MODE_OK will be
|
|
* removed from the list, and if @verbose the status code and mode name is also
|
|
* printed to dmesg.
|
|
*/
|
|
void drm_mode_prune_invalid(struct drm_device *dev,
|
|
struct list_head *mode_list, bool verbose)
|
|
{
|
|
struct drm_display_mode *mode, *t;
|
|
|
|
list_for_each_entry_safe(mode, t, mode_list, head) {
|
|
if (mode->status != MODE_OK) {
|
|
list_del(&mode->head);
|
|
if (verbose) {
|
|
drm_mode_debug_printmodeline(mode);
|
|
DRM_DEBUG_KMS("Not using %s mode: %s\n",
|
|
mode->name,
|
|
drm_get_mode_status_name(mode->status));
|
|
}
|
|
drm_mode_destroy(dev, mode);
|
|
}
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_prune_invalid);
|
|
|
|
/**
|
|
* drm_mode_compare - compare modes for favorability
|
|
* @priv: unused
|
|
* @lh_a: list_head for first mode
|
|
* @lh_b: list_head for second mode
|
|
*
|
|
* Compare two modes, given by @lh_a and @lh_b, returning a value indicating
|
|
* which is better.
|
|
*
|
|
* Returns:
|
|
* Negative if @lh_a is better than @lh_b, zero if they're equivalent, or
|
|
* positive if @lh_b is better than @lh_a.
|
|
*/
|
|
static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head *lh_b)
|
|
{
|
|
struct drm_display_mode *a = list_entry(lh_a, struct drm_display_mode, head);
|
|
struct drm_display_mode *b = list_entry(lh_b, struct drm_display_mode, head);
|
|
int diff;
|
|
|
|
diff = ((b->type & DRM_MODE_TYPE_PREFERRED) != 0) -
|
|
((a->type & DRM_MODE_TYPE_PREFERRED) != 0);
|
|
if (diff)
|
|
return diff;
|
|
diff = b->hdisplay * b->vdisplay - a->hdisplay * a->vdisplay;
|
|
if (diff)
|
|
return diff;
|
|
|
|
diff = drm_mode_vrefresh(b) - drm_mode_vrefresh(a);
|
|
if (diff)
|
|
return diff;
|
|
|
|
diff = b->clock - a->clock;
|
|
return diff;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_sort - sort mode list
|
|
* @mode_list: list of drm_display_mode structures to sort
|
|
*
|
|
* Sort @mode_list by favorability, moving good modes to the head of the list.
|
|
*/
|
|
void drm_mode_sort(struct list_head *mode_list)
|
|
{
|
|
list_sort(NULL, mode_list, drm_mode_compare);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_sort);
|
|
|
|
/**
|
|
* drm_connector_list_update - update the mode list for the connector
|
|
* @connector: the connector to update
|
|
*
|
|
* This moves the modes from the @connector probed_modes list
|
|
* to the actual mode list. It compares the probed mode against the current
|
|
* list and only adds different/new modes.
|
|
*
|
|
* This is just a helper functions doesn't validate any modes itself and also
|
|
* doesn't prune any invalid modes. Callers need to do that themselves.
|
|
*/
|
|
void drm_connector_list_update(struct drm_connector *connector)
|
|
{
|
|
struct drm_display_mode *pmode, *pt;
|
|
|
|
WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex));
|
|
|
|
list_for_each_entry_safe(pmode, pt, &connector->probed_modes, head) {
|
|
struct drm_display_mode *mode;
|
|
bool found_it = false;
|
|
|
|
/* go through current modes checking for the new probed mode */
|
|
list_for_each_entry(mode, &connector->modes, head) {
|
|
if (!drm_mode_equal(pmode, mode))
|
|
continue;
|
|
|
|
found_it = true;
|
|
|
|
/*
|
|
* If the old matching mode is stale (ie. left over
|
|
* from a previous probe) just replace it outright.
|
|
* Otherwise just merge the type bits between all
|
|
* equal probed modes.
|
|
*
|
|
* If two probed modes are considered equal, pick the
|
|
* actual timings from the one that's marked as
|
|
* preferred (in case the match isn't 100%). If
|
|
* multiple or zero preferred modes are present, favor
|
|
* the mode added to the probed_modes list first.
|
|
*/
|
|
if (mode->status == MODE_STALE) {
|
|
drm_mode_copy(mode, pmode);
|
|
} else if ((mode->type & DRM_MODE_TYPE_PREFERRED) == 0 &&
|
|
(pmode->type & DRM_MODE_TYPE_PREFERRED) != 0) {
|
|
pmode->type |= mode->type;
|
|
drm_mode_copy(mode, pmode);
|
|
} else {
|
|
mode->type |= pmode->type;
|
|
}
|
|
|
|
list_del(&pmode->head);
|
|
drm_mode_destroy(connector->dev, pmode);
|
|
break;
|
|
}
|
|
|
|
if (!found_it) {
|
|
list_move_tail(&pmode->head, &connector->modes);
|
|
}
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(drm_connector_list_update);
|
|
|
|
static int drm_mode_parse_cmdline_bpp(const char *str, char **end_ptr,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
unsigned int bpp;
|
|
|
|
if (str[0] != '-')
|
|
return -EINVAL;
|
|
|
|
str++;
|
|
bpp = simple_strtol(str, end_ptr, 10);
|
|
if (*end_ptr == str)
|
|
return -EINVAL;
|
|
|
|
mode->bpp = bpp;
|
|
mode->bpp_specified = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_cmdline_refresh(const char *str, char **end_ptr,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
unsigned int refresh;
|
|
|
|
if (str[0] != '@')
|
|
return -EINVAL;
|
|
|
|
str++;
|
|
refresh = simple_strtol(str, end_ptr, 10);
|
|
if (*end_ptr == str)
|
|
return -EINVAL;
|
|
|
|
mode->refresh = refresh;
|
|
mode->refresh_specified = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_cmdline_extra(const char *str, int length,
|
|
bool freestanding,
|
|
const struct drm_connector *connector,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
switch (str[i]) {
|
|
case 'i':
|
|
if (freestanding)
|
|
return -EINVAL;
|
|
|
|
mode->interlace = true;
|
|
break;
|
|
case 'm':
|
|
if (freestanding)
|
|
return -EINVAL;
|
|
|
|
mode->margins = true;
|
|
break;
|
|
case 'D':
|
|
if (mode->force != DRM_FORCE_UNSPECIFIED)
|
|
return -EINVAL;
|
|
|
|
if ((connector->connector_type != DRM_MODE_CONNECTOR_DVII) &&
|
|
(connector->connector_type != DRM_MODE_CONNECTOR_HDMIB))
|
|
mode->force = DRM_FORCE_ON;
|
|
else
|
|
mode->force = DRM_FORCE_ON_DIGITAL;
|
|
break;
|
|
case 'd':
|
|
if (mode->force != DRM_FORCE_UNSPECIFIED)
|
|
return -EINVAL;
|
|
|
|
mode->force = DRM_FORCE_OFF;
|
|
break;
|
|
case 'e':
|
|
if (mode->force != DRM_FORCE_UNSPECIFIED)
|
|
return -EINVAL;
|
|
|
|
mode->force = DRM_FORCE_ON;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length,
|
|
bool extras,
|
|
const struct drm_connector *connector,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
const char *str_start = str;
|
|
bool rb = false, cvt = false;
|
|
int xres = 0, yres = 0;
|
|
int remaining, i;
|
|
char *end_ptr;
|
|
|
|
xres = simple_strtol(str, &end_ptr, 10);
|
|
if (end_ptr == str)
|
|
return -EINVAL;
|
|
|
|
if (end_ptr[0] != 'x')
|
|
return -EINVAL;
|
|
end_ptr++;
|
|
|
|
str = end_ptr;
|
|
yres = simple_strtol(str, &end_ptr, 10);
|
|
if (end_ptr == str)
|
|
return -EINVAL;
|
|
|
|
remaining = length - (end_ptr - str_start);
|
|
if (remaining < 0)
|
|
return -EINVAL;
|
|
|
|
for (i = 0; i < remaining; i++) {
|
|
switch (end_ptr[i]) {
|
|
case 'M':
|
|
cvt = true;
|
|
break;
|
|
case 'R':
|
|
rb = true;
|
|
break;
|
|
default:
|
|
/*
|
|
* Try to pass that to our extras parsing
|
|
* function to handle the case where the
|
|
* extras are directly after the resolution
|
|
*/
|
|
if (extras) {
|
|
int ret = drm_mode_parse_cmdline_extra(end_ptr + i,
|
|
1,
|
|
false,
|
|
connector,
|
|
mode);
|
|
if (ret)
|
|
return ret;
|
|
} else {
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
}
|
|
|
|
mode->xres = xres;
|
|
mode->yres = yres;
|
|
mode->cvt = cvt;
|
|
mode->rb = rb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_cmdline_int(const char *delim, unsigned int *int_ret)
|
|
{
|
|
const char *value;
|
|
char *endp;
|
|
|
|
/*
|
|
* delim must point to the '=', otherwise it is a syntax error and
|
|
* if delim points to the terminating zero, then delim + 1 wil point
|
|
* past the end of the string.
|
|
*/
|
|
if (*delim != '=')
|
|
return -EINVAL;
|
|
|
|
value = delim + 1;
|
|
*int_ret = simple_strtol(value, &endp, 10);
|
|
|
|
/* Make sure we have parsed something */
|
|
if (endp == value)
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_panel_orientation(const char *delim,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
const char *value;
|
|
|
|
if (*delim != '=')
|
|
return -EINVAL;
|
|
|
|
value = delim + 1;
|
|
delim = strchr(value, ',');
|
|
if (!delim)
|
|
delim = value + strlen(value);
|
|
|
|
if (!strncmp(value, "normal", delim - value))
|
|
mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
|
|
else if (!strncmp(value, "upside_down", delim - value))
|
|
mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
|
|
else if (!strncmp(value, "left_side_up", delim - value))
|
|
mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
|
|
else if (!strncmp(value, "right_side_up", delim - value))
|
|
mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
|
|
else
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int drm_mode_parse_cmdline_options(const char *str,
|
|
bool freestanding,
|
|
const struct drm_connector *connector,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
unsigned int deg, margin, rotation = 0;
|
|
const char *delim, *option, *sep;
|
|
|
|
option = str;
|
|
do {
|
|
delim = strchr(option, '=');
|
|
if (!delim) {
|
|
delim = strchr(option, ',');
|
|
|
|
if (!delim)
|
|
delim = option + strlen(option);
|
|
}
|
|
|
|
if (!strncmp(option, "rotate", delim - option)) {
|
|
if (drm_mode_parse_cmdline_int(delim, °))
|
|
return -EINVAL;
|
|
|
|
switch (deg) {
|
|
case 0:
|
|
rotation |= DRM_MODE_ROTATE_0;
|
|
break;
|
|
|
|
case 90:
|
|
rotation |= DRM_MODE_ROTATE_90;
|
|
break;
|
|
|
|
case 180:
|
|
rotation |= DRM_MODE_ROTATE_180;
|
|
break;
|
|
|
|
case 270:
|
|
rotation |= DRM_MODE_ROTATE_270;
|
|
break;
|
|
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
} else if (!strncmp(option, "reflect_x", delim - option)) {
|
|
rotation |= DRM_MODE_REFLECT_X;
|
|
} else if (!strncmp(option, "reflect_y", delim - option)) {
|
|
rotation |= DRM_MODE_REFLECT_Y;
|
|
} else if (!strncmp(option, "margin_right", delim - option)) {
|
|
if (drm_mode_parse_cmdline_int(delim, &margin))
|
|
return -EINVAL;
|
|
|
|
mode->tv_margins.right = margin;
|
|
} else if (!strncmp(option, "margin_left", delim - option)) {
|
|
if (drm_mode_parse_cmdline_int(delim, &margin))
|
|
return -EINVAL;
|
|
|
|
mode->tv_margins.left = margin;
|
|
} else if (!strncmp(option, "margin_top", delim - option)) {
|
|
if (drm_mode_parse_cmdline_int(delim, &margin))
|
|
return -EINVAL;
|
|
|
|
mode->tv_margins.top = margin;
|
|
} else if (!strncmp(option, "margin_bottom", delim - option)) {
|
|
if (drm_mode_parse_cmdline_int(delim, &margin))
|
|
return -EINVAL;
|
|
|
|
mode->tv_margins.bottom = margin;
|
|
} else if (!strncmp(option, "panel_orientation", delim - option)) {
|
|
if (drm_mode_parse_panel_orientation(delim, mode))
|
|
return -EINVAL;
|
|
} else {
|
|
return -EINVAL;
|
|
}
|
|
sep = strchr(delim, ',');
|
|
option = sep + 1;
|
|
} while (sep);
|
|
|
|
if (rotation && freestanding)
|
|
return -EINVAL;
|
|
|
|
if (!(rotation & DRM_MODE_ROTATE_MASK))
|
|
rotation |= DRM_MODE_ROTATE_0;
|
|
|
|
/* Make sure there is exactly one rotation defined */
|
|
if (!is_power_of_2(rotation & DRM_MODE_ROTATE_MASK))
|
|
return -EINVAL;
|
|
|
|
mode->rotation_reflection = rotation;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const char * const drm_named_modes_whitelist[] = {
|
|
"NTSC",
|
|
"PAL",
|
|
};
|
|
|
|
/**
|
|
* drm_mode_parse_command_line_for_connector - parse command line modeline for connector
|
|
* @mode_option: optional per connector mode option
|
|
* @connector: connector to parse modeline for
|
|
* @mode: preallocated drm_cmdline_mode structure to fill out
|
|
*
|
|
* This parses @mode_option command line modeline for modes and options to
|
|
* configure the connector. If @mode_option is NULL the default command line
|
|
* modeline in fb_mode_option will be parsed instead.
|
|
*
|
|
* This uses the same parameters as the fb modedb.c, except for an extra
|
|
* force-enable, force-enable-digital and force-disable bit at the end::
|
|
*
|
|
* <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
|
|
*
|
|
* Additionals options can be provided following the mode, using a comma to
|
|
* separate each option. Valid options can be found in
|
|
* Documentation/fb/modedb.rst.
|
|
*
|
|
* The intermediate drm_cmdline_mode structure is required to store additional
|
|
* options from the command line modline like the force-enable/disable flag.
|
|
*
|
|
* Returns:
|
|
* True if a valid modeline has been parsed, false otherwise.
|
|
*/
|
|
bool drm_mode_parse_command_line_for_connector(const char *mode_option,
|
|
const struct drm_connector *connector,
|
|
struct drm_cmdline_mode *mode)
|
|
{
|
|
const char *name;
|
|
bool freestanding = false, parse_extras = false;
|
|
unsigned int bpp_off = 0, refresh_off = 0, options_off = 0;
|
|
unsigned int mode_end = 0;
|
|
const char *bpp_ptr = NULL, *refresh_ptr = NULL, *extra_ptr = NULL;
|
|
const char *options_ptr = NULL;
|
|
char *bpp_end_ptr = NULL, *refresh_end_ptr = NULL;
|
|
int i, len, ret;
|
|
|
|
memset(mode, 0, sizeof(*mode));
|
|
mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
|
|
|
|
if (!mode_option)
|
|
return false;
|
|
|
|
name = mode_option;
|
|
|
|
/* Try to locate the bpp and refresh specifiers, if any */
|
|
bpp_ptr = strchr(name, '-');
|
|
if (bpp_ptr)
|
|
bpp_off = bpp_ptr - name;
|
|
|
|
refresh_ptr = strchr(name, '@');
|
|
if (refresh_ptr)
|
|
refresh_off = refresh_ptr - name;
|
|
|
|
/* Locate the start of named options */
|
|
options_ptr = strchr(name, ',');
|
|
if (options_ptr)
|
|
options_off = options_ptr - name;
|
|
|
|
/* Locate the end of the name / resolution, and parse it */
|
|
if (bpp_ptr) {
|
|
mode_end = bpp_off;
|
|
} else if (refresh_ptr) {
|
|
mode_end = refresh_off;
|
|
} else if (options_ptr) {
|
|
mode_end = options_off;
|
|
parse_extras = true;
|
|
} else {
|
|
mode_end = strlen(name);
|
|
parse_extras = true;
|
|
}
|
|
|
|
/* First check for a named mode */
|
|
for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) {
|
|
ret = str_has_prefix(name, drm_named_modes_whitelist[i]);
|
|
if (ret == mode_end) {
|
|
if (refresh_ptr)
|
|
return false; /* named + refresh is invalid */
|
|
|
|
strcpy(mode->name, drm_named_modes_whitelist[i]);
|
|
mode->specified = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* No named mode? Check for a normal mode argument, e.g. 1024x768 */
|
|
if (!mode->specified && isdigit(name[0])) {
|
|
ret = drm_mode_parse_cmdline_res_mode(name, mode_end,
|
|
parse_extras,
|
|
connector,
|
|
mode);
|
|
if (ret)
|
|
return false;
|
|
|
|
mode->specified = true;
|
|
}
|
|
|
|
/* No mode? Check for freestanding extras and/or options */
|
|
if (!mode->specified) {
|
|
unsigned int len = strlen(mode_option);
|
|
|
|
if (bpp_ptr || refresh_ptr)
|
|
return false; /* syntax error */
|
|
|
|
if (len == 1 || (len >= 2 && mode_option[1] == ','))
|
|
extra_ptr = mode_option;
|
|
else
|
|
options_ptr = mode_option - 1;
|
|
|
|
freestanding = true;
|
|
}
|
|
|
|
if (bpp_ptr) {
|
|
ret = drm_mode_parse_cmdline_bpp(bpp_ptr, &bpp_end_ptr, mode);
|
|
if (ret)
|
|
return false;
|
|
|
|
mode->bpp_specified = true;
|
|
}
|
|
|
|
if (refresh_ptr) {
|
|
ret = drm_mode_parse_cmdline_refresh(refresh_ptr,
|
|
&refresh_end_ptr, mode);
|
|
if (ret)
|
|
return false;
|
|
|
|
mode->refresh_specified = true;
|
|
}
|
|
|
|
/*
|
|
* Locate the end of the bpp / refresh, and parse the extras
|
|
* if relevant
|
|
*/
|
|
if (bpp_ptr && refresh_ptr)
|
|
extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
|
|
else if (bpp_ptr)
|
|
extra_ptr = bpp_end_ptr;
|
|
else if (refresh_ptr)
|
|
extra_ptr = refresh_end_ptr;
|
|
|
|
if (extra_ptr) {
|
|
if (options_ptr)
|
|
len = options_ptr - extra_ptr;
|
|
else
|
|
len = strlen(extra_ptr);
|
|
|
|
ret = drm_mode_parse_cmdline_extra(extra_ptr, len, freestanding,
|
|
connector, mode);
|
|
if (ret)
|
|
return false;
|
|
}
|
|
|
|
if (options_ptr) {
|
|
ret = drm_mode_parse_cmdline_options(options_ptr + 1,
|
|
freestanding,
|
|
connector, mode);
|
|
if (ret)
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_parse_command_line_for_connector);
|
|
|
|
/**
|
|
* drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode
|
|
* @dev: DRM device to create the new mode for
|
|
* @cmd: input command line modeline
|
|
*
|
|
* Returns:
|
|
* Pointer to converted mode on success, NULL on error.
|
|
*/
|
|
struct drm_display_mode *
|
|
drm_mode_create_from_cmdline_mode(struct drm_device *dev,
|
|
struct drm_cmdline_mode *cmd)
|
|
{
|
|
struct drm_display_mode *mode;
|
|
|
|
if (cmd->cvt)
|
|
mode = drm_cvt_mode(dev,
|
|
cmd->xres, cmd->yres,
|
|
cmd->refresh_specified ? cmd->refresh : 60,
|
|
cmd->rb, cmd->interlace,
|
|
cmd->margins);
|
|
else
|
|
mode = drm_gtf_mode(dev,
|
|
cmd->xres, cmd->yres,
|
|
cmd->refresh_specified ? cmd->refresh : 60,
|
|
cmd->interlace,
|
|
cmd->margins);
|
|
if (!mode)
|
|
return NULL;
|
|
|
|
mode->type |= DRM_MODE_TYPE_USERDEF;
|
|
/* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */
|
|
if (cmd->xres == 1366)
|
|
drm_mode_fixup_1366x768(mode);
|
|
drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
|
|
return mode;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_create_from_cmdline_mode);
|
|
|
|
/**
|
|
* drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo
|
|
* @out: drm_mode_modeinfo struct to return to the user
|
|
* @in: drm_display_mode to use
|
|
*
|
|
* Convert a drm_display_mode into a drm_mode_modeinfo structure to return to
|
|
* the user.
|
|
*/
|
|
void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
|
|
const struct drm_display_mode *in)
|
|
{
|
|
out->clock = in->clock;
|
|
out->hdisplay = in->hdisplay;
|
|
out->hsync_start = in->hsync_start;
|
|
out->hsync_end = in->hsync_end;
|
|
out->htotal = in->htotal;
|
|
out->hskew = in->hskew;
|
|
out->vdisplay = in->vdisplay;
|
|
out->vsync_start = in->vsync_start;
|
|
out->vsync_end = in->vsync_end;
|
|
out->vtotal = in->vtotal;
|
|
out->vscan = in->vscan;
|
|
out->vrefresh = drm_mode_vrefresh(in);
|
|
out->flags = in->flags;
|
|
out->type = in->type;
|
|
|
|
switch (in->picture_aspect_ratio) {
|
|
case HDMI_PICTURE_ASPECT_4_3:
|
|
out->flags |= DRM_MODE_FLAG_PIC_AR_4_3;
|
|
break;
|
|
case HDMI_PICTURE_ASPECT_16_9:
|
|
out->flags |= DRM_MODE_FLAG_PIC_AR_16_9;
|
|
break;
|
|
case HDMI_PICTURE_ASPECT_64_27:
|
|
out->flags |= DRM_MODE_FLAG_PIC_AR_64_27;
|
|
break;
|
|
case HDMI_PICTURE_ASPECT_256_135:
|
|
out->flags |= DRM_MODE_FLAG_PIC_AR_256_135;
|
|
break;
|
|
default:
|
|
WARN(1, "Invalid aspect ratio (0%x) on mode\n",
|
|
in->picture_aspect_ratio);
|
|
fallthrough;
|
|
case HDMI_PICTURE_ASPECT_NONE:
|
|
out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
|
|
break;
|
|
}
|
|
|
|
strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
|
|
out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_mode_convert_to_umode);
|
|
|
|
/**
|
|
* drm_crtc_convert_umode - convert a modeinfo into a drm_display_mode
|
|
* @dev: drm device
|
|
* @out: drm_display_mode to return to the user
|
|
* @in: drm_mode_modeinfo to use
|
|
*
|
|
* Convert a drm_mode_modeinfo into a drm_display_mode structure to return to
|
|
* the caller.
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative errno on failure.
|
|
*/
|
|
int drm_mode_convert_umode(struct drm_device *dev,
|
|
struct drm_display_mode *out,
|
|
const struct drm_mode_modeinfo *in)
|
|
{
|
|
if (in->clock > INT_MAX || in->vrefresh > INT_MAX)
|
|
return -ERANGE;
|
|
|
|
out->clock = in->clock;
|
|
out->hdisplay = in->hdisplay;
|
|
out->hsync_start = in->hsync_start;
|
|
out->hsync_end = in->hsync_end;
|
|
out->htotal = in->htotal;
|
|
out->hskew = in->hskew;
|
|
out->vdisplay = in->vdisplay;
|
|
out->vsync_start = in->vsync_start;
|
|
out->vsync_end = in->vsync_end;
|
|
out->vtotal = in->vtotal;
|
|
out->vscan = in->vscan;
|
|
out->flags = in->flags;
|
|
/*
|
|
* Old xf86-video-vmware (possibly others too) used to
|
|
* leave 'type' unititialized. Just ignore any bits we
|
|
* don't like. It's a just hint after all, and more
|
|
* useful for the kernel->userspace direction anyway.
|
|
*/
|
|
out->type = in->type & DRM_MODE_TYPE_ALL;
|
|
strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
|
|
out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
|
|
|
|
/* Clearing picture aspect ratio bits from out flags,
|
|
* as the aspect-ratio information is not stored in
|
|
* flags for kernel-mode, but in picture_aspect_ratio.
|
|
*/
|
|
out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
|
|
|
|
switch (in->flags & DRM_MODE_FLAG_PIC_AR_MASK) {
|
|
case DRM_MODE_FLAG_PIC_AR_4_3:
|
|
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3;
|
|
break;
|
|
case DRM_MODE_FLAG_PIC_AR_16_9:
|
|
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9;
|
|
break;
|
|
case DRM_MODE_FLAG_PIC_AR_64_27:
|
|
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27;
|
|
break;
|
|
case DRM_MODE_FLAG_PIC_AR_256_135:
|
|
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135;
|
|
break;
|
|
case DRM_MODE_FLAG_PIC_AR_NONE:
|
|
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
out->status = drm_mode_validate_driver(dev, out);
|
|
if (out->status != MODE_OK)
|
|
return -EINVAL;
|
|
|
|
drm_mode_set_crtcinfo(out, CRTC_INTERLACE_HALVE_V);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_mode_convert_umode);
|
|
|
|
/**
|
|
* drm_mode_is_420_only - if a given videomode can be only supported in YCBCR420
|
|
* output format
|
|
*
|
|
* @display: display under action
|
|
* @mode: video mode to be tested.
|
|
*
|
|
* Returns:
|
|
* true if the mode can be supported in YCBCR420 format
|
|
* false if not.
|
|
*/
|
|
bool drm_mode_is_420_only(const struct drm_display_info *display,
|
|
const struct drm_display_mode *mode)
|
|
{
|
|
u8 vic = drm_match_cea_mode(mode);
|
|
|
|
return test_bit(vic, display->hdmi.y420_vdb_modes);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_is_420_only);
|
|
|
|
/**
|
|
* drm_mode_is_420_also - if a given videomode can be supported in YCBCR420
|
|
* output format also (along with RGB/YCBCR444/422)
|
|
*
|
|
* @display: display under action.
|
|
* @mode: video mode to be tested.
|
|
*
|
|
* Returns:
|
|
* true if the mode can be support YCBCR420 format
|
|
* false if not.
|
|
*/
|
|
bool drm_mode_is_420_also(const struct drm_display_info *display,
|
|
const struct drm_display_mode *mode)
|
|
{
|
|
u8 vic = drm_match_cea_mode(mode);
|
|
|
|
return test_bit(vic, display->hdmi.y420_cmdb_modes);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_is_420_also);
|
|
/**
|
|
* drm_mode_is_420 - if a given videomode can be supported in YCBCR420
|
|
* output format
|
|
*
|
|
* @display: display under action.
|
|
* @mode: video mode to be tested.
|
|
*
|
|
* Returns:
|
|
* true if the mode can be supported in YCBCR420 format
|
|
* false if not.
|
|
*/
|
|
bool drm_mode_is_420(const struct drm_display_info *display,
|
|
const struct drm_display_mode *mode)
|
|
{
|
|
return drm_mode_is_420_only(display, mode) ||
|
|
drm_mode_is_420_also(display, mode);
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_is_420);
|