
Changes in 5.10.181 driver core: add a helper to setup both the of_node and fwnode of a device drm/mipi-dsi: Set the fwnode for mipi_dsi_device ARM: 9296/1: HP Jornada 7XX: fix kernel-doc warnings net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe() linux/dim: Do nothing if no time delta between samples net: Fix load-tearing on sk->sk_stamp in sock_recv_cmsgs(). netfilter: conntrack: fix possible bug_on with enable_hooks=1 netlink: annotate accesses to nlk->cb_running net: annotate sk->sk_err write from do_recvmmsg() net: deal with most data-races in sk_wait_event() net: tap: check vlan with eth_type_vlan() method net: add vlan_get_protocol_and_depth() helper tcp: factor out __tcp_close() helper tcp: add annotations around sk->sk_shutdown accesses ipvlan:Fix out-of-bounds caused by unclear skb->cb net: datagram: fix data-races in datagram_poll() af_unix: Fix a data race of sk->sk_receive_queue->qlen. af_unix: Fix data races around sk->sk_shutdown. drm/i915/dp: prevent potential div-by-zero fbdev: arcfb: Fix error handling in arcfb_probe() ext4: remove an unused variable warning with CONFIG_QUOTA=n ext4: reflect error codes from ext4_multi_mount_protect() to its callers ext4: don't clear SB_RDONLY when remounting r/w until quota is re-enabled ext4: fix lockdep warning when enabling MMP ext4: remove redundant mb_regenerate_buddy() ext4: drop s_mb_bal_lock and convert protected fields to atomic ext4: add mballoc stats proc file ext4: allow to find by goal if EXT4_MB_HINT_GOAL_ONLY is set ext4: allow ext4_get_group_info() to fail refscale: Move shutdown from wait_event() to wait_event_idle() rcu: Protect rcu_print_task_exp_stall() ->exp_tasks access fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() drm/amd/display: Use DC_LOG_DC in the trasform pixel function regmap: cache: Return error in cache sync operations for REGCACHE_NONE arm64: dts: qcom: msm8996: Add missing DWC3 quirks memstick: r592: Fix UAF bug in r592_remove due to race condition firmware: arm_sdei: Fix sleep from invalid context BUG ACPI: EC: Fix oops when removing custom query handlers remoteproc: stm32_rproc: Add mutex protection for workqueue drm/tegra: Avoid potential 32-bit integer overflow ACPICA: Avoid undefined behavior: applying zero offset to null pointer ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects drm/amd: Fix an out of bounds error in BIOS parser wifi: ath: Silence memcpy run-time false positive warning bpf: Annotate data races in bpf_local_storage wifi: brcmfmac: cfg80211: Pass the PMK in binary instead of hex ext2: Check block size validity during mount scsi: lpfc: Prevent lpfc_debugfs_lockstat_write() buffer overflow net: pasemi: Fix return type of pasemi_mac_start_tx() net: Catch invalid index in XPS mapping scsi: target: iscsit: Free cmds before session free lib: cpu_rmap: Avoid use after free on rmap->obj array entries scsi: message: mptlan: Fix use after free bug in mptlan_remove() due to race condition gfs2: Fix inode height consistency check ext4: set goal start correctly in ext4_mb_normalize_request ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa() f2fs: fix to drop all dirty pages during umount() if cp_error is set samples/bpf: Fix fout leak in hbm's run_bpf_prog wifi: iwlwifi: pcie: fix possible NULL pointer dereference wifi: iwlwifi: pcie: Fix integer overflow in iwl_write_to_user_buf null_blk: Always check queue mode setting from configfs wifi: iwlwifi: dvm: Fix memcpy: detected field-spanning write backtrace wifi: ath11k: Fix SKB corruption in REO destination ring ipvs: Update width of source for ip_vs_sync_conn_options Bluetooth: hci_bcm: Fall back to getting bdaddr from EFI if not set Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE HID: logitech-hidpp: Don't use the USB serial for USB devices HID: logitech-hidpp: Reconcile USB and Unifying serials spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 HID: wacom: generic: Set battery quirk only when we see battery data usb: typec: tcpm: fix multiple times discover svids error serial: 8250: Reinit port->pm on port specific driver unbind mcb-pci: Reallocate memory region to avoid memory overlapping sched: Fix KCSAN noinstr violation recordmcount: Fix memory leaks in the uwrite function RDMA/core: Fix multiple -Warray-bounds warnings iommu/arm-smmu-qcom: Limit the SMR groups to 128 clk: tegra20: fix gcc-7 constant overflow warning iommu/arm-smmu-v3: Acknowledge pri/event queue overflow if any Input: xpad - add constants for GIP interface numbers phy: st: miphy28lp: use _poll_timeout functions for waits mfd: dln2: Fix memory leak in dln2_probe() btrfs: move btrfs_find_highest_objectid/btrfs_find_free_objectid to disk-io.c btrfs: replace calls to btrfs_find_free_ino with btrfs_find_free_objectid btrfs: fix space cache inconsistency after error loading it from disk xfrm: don't check the default policy if the policy allows the packet Revert "Fix XFRM-I support for nested ESP tunnels" drm/msm/dp: unregister audio driver during unbind drm/msm/dpu: Remove duplicate register defines from INTF cpupower: Make TSC read per CPU for Mperf monitor af_key: Reject optional tunnel/BEET mode templates in outbound policies net: fec: Better handle pm_runtime_get() failing in .remove() net: phy: dp83867: add w/a for packet errors seen with short cables ALSA: firewire-digi00x: prevent potential use after free ALSA: hda/realtek: Apply HP B&O top speaker profile to Pavilion 15 vsock: avoid to close connected socket after the timeout ipv4/tcp: do not use per netns ctl sockets net: Find dst with sk's xfrm policy not ctl_sk tcp: fix possible sk_priority leak in tcp_v4_send_reset() serial: arc_uart: fix of_iomap leak in `arc_serial_probe` erspan: get the proto with the md version for collect_md net: hns3: fix sending pfc frames after reset issue net: hns3: fix reset delay time to avoid configuration timeout media: netup_unidvb: fix use-after-free at del_timer() SUNRPC: Fix trace_svc_register() call site drm/exynos: fix g2d_open/close helper function definitions net: nsh: Use correct mac_offset to unwind gso skb in nsh_gso_segment() net/tipc: fix tipc header files for kernel-doc tipc: add tipc_bearer_min_mtu to calculate min mtu tipc: do not update mtu if msg_max is too small in mtu negotiation tipc: check the bearer min mtu properly when setting it by netlink net: bcmgenet: Remove phy_stop() from bcmgenet_netif_stop() net: bcmgenet: Restore phy_stop() depending upon suspend/close wifi: mac80211: fix min center freq offset tracing wifi: iwlwifi: mvm: don't trust firmware n_channels scsi: storvsc: Don't pass unused PFNs to Hyper-V host cassini: Fix a memory leak in the error handling path of cas_init_one() igb: fix bit_shift to be in [1..8] range vlan: fix a potential uninit-value in vlan_dev_hard_start_xmit() netfilter: nft_set_rbtree: fix null deref on element insertion bridge: always declare tunnel functions ALSA: usb-audio: Add a sample rate workaround for Line6 Pod Go USB: usbtmc: Fix direction for 0-length ioctl control messages usb-storage: fix deadlock when a scsi command timeouts more than once USB: UHCI: adjust zhaoxin UHCI controllers OverCurrent bit value usb: dwc3: debugfs: Resume dwc3 before accessing registers usb: gadget: u_ether: Fix host MAC address case usb: typec: altmodes/displayport: fix pin_assignment_show ALSA: hda: Fix Oops by 9.1 surround channel names ALSA: hda: Add NVIDIA codec IDs a3 through a7 to patch table ALSA: hda/realtek: Add quirk for Clevo L140AU ALSA: hda/realtek: Add a quirk for HP EliteDesk 805 ALSA: hda/realtek: Add quirk for 2nd ASUS GU603 can: j1939: recvmsg(): allow MSG_CMSG_COMPAT flag can: isotp: recvmsg(): allow MSG_CMSG_COMPAT flag can: kvaser_pciefd: Set CAN_STATE_STOPPED in kvaser_pciefd_stop() can: kvaser_pciefd: Call request_irq() before enabling interrupts can: kvaser_pciefd: Empty SRB buffer in probe can: kvaser_pciefd: Clear listen-only bit if not explicitly requested can: kvaser_pciefd: Do not send EFLUSH command on TFD interrupt can: kvaser_pciefd: Disable interrupts in probe error path statfs: enforce statfs[64] structure initialization serial: Add support for Advantech PCI-1611U card vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF ceph: force updating the msg pointer in non-split case tpm/tpm_tis: Disable interrupts for more Lenovo devices powerpc/64s/radix: Fix soft dirty tracking nilfs2: fix use-after-free bug of nilfs_root in nilfs_evict_inode() HID: wacom: Force pen out of prox if no events have been received in a while HID: wacom: Add new Intuos Pro Small (PTH-460) device IDs HID: wacom: add three styli to wacom_intuos_get_tool_type KVM: arm64: Link position-independent string routines into .hyp.text serial: 8250_exar: derive nr_ports from PCI ID for Acces I/O cards serial: exar: Add support for Sealevel 7xxxC serial cards serial: 8250_exar: Add support for USR298x PCI Modems s390/qdio: get rid of register asm s390/qdio: fix do_sqbs() inline assembly constraint watchdog: sp5100_tco: Immediately trigger upon starting. ARM: dts: stm32: fix AV96 board SAI2 pin muxing on stm32mp15 writeback, cgroup: remove extra percpu_ref_exit() net/sched: act_mirred: refactor the handle of xmit net/sched: act_mirred: better wording on protection against excessive stack growth act_mirred: use the backlog for nested calls to mirred ingress spi: fsl-spi: Re-organise transfer bits_per_word adaptation spi: fsl-cpm: Use 16 bit mode for large transfers with even size ocfs2: Switch to security_inode_init_security() ALSA: hda/ca0132: add quirk for EVGA X299 DARK ALSA: hda: Fix unhandled register update during auto-suspend period ALSA: hda/realtek: Enable headset onLenovo M70/M90 net: cdc_ncm: Deal with too low values of dwNtbOutMaxSize m68k: Move signal frame following exception on 68020/030 parisc: Handle kgdb breakpoints only in kernel context parisc: Allow to reboot machine after system halt gpio: mockup: Fix mode of debugfs files btrfs: use nofs when cleaning up aborted transactions dt-binding: cdns,usb3: Fix cdns,on-chip-buff-size type x86/mm: Avoid incomplete Global INVLPG flushes selftests/memfd: Fix unknown type name build failure parisc: Fix flush_dcache_page() for usage from irq context x86/topology: Fix erroneous smp_num_siblings on Intel Hybrid platforms debugobjects: Don't wake up kswapd from fill_pool() fbdev: udlfb: Fix endpoint check net: fix stack overflow when LRO is disabled for virtual interfaces udplite: Fix NULL pointer dereference in __sk_mem_raise_allocated(). USB: core: Add routines for endpoint checks in old drivers USB: sisusbvga: Add endpoint checks media: radio-shark: Add endpoint checks net: fix skb leak in __skb_tstamp_tx() selftests: fib_tests: mute cleanup error message octeontx2-pf: Fix TSOv6 offload bpf: Fix mask generation for 32-bit narrow loads of 64-bit fields ipv6: Fix out-of-bounds access in ipv6_find_tlv() power: supply: leds: Fix blink to LED on transition power: supply: bq27xxx: Fix bq27xxx_battery_update() race condition power: supply: bq27xxx: Fix I2C IRQ race on remove power: supply: bq27xxx: Fix poll_interval handling and races on remove power: supply: sbs-charger: Fix INHIBITED bit for Status reg fs: fix undefined behavior in bit shift for SB_NOUSER coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet() xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() x86/show_trace_log_lvl: Ensure stack pointer is aligned, again ASoC: Intel: Skylake: Fix declaration of enum skl_ch_cfg forcedeth: Fix an error handling path in nv_probe() net/mlx5e: do as little as possible in napi poll when budget is 0 net/mlx5: DR, Fix crc32 calculation to work on big-endian (BE) CPUs net/mlx5: Fix error message when failing to allocate device memory net/mlx5: Devcom, fix error flow in mlx5_devcom_register_device arm64: dts: imx8mn-var-som: fix PHY detection bug by adding deassert delay 3c589_cs: Fix an error handling path in tc589_probe() net: phy: mscc: add VSC8502 to MODULE_DEVICE_TABLE Linux 5.10.181 Change-Id: Iaad0b0bb7c1ad061b28ad4ee16e03db935241177 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1268 lines
31 KiB
C
1268 lines
31 KiB
C
/*
|
|
* MIPI DSI Bus
|
|
*
|
|
* Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd.
|
|
* Andrzej Hajda <a.hajda@samsung.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, sub license, 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 (including the
|
|
* next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
|
|
*/
|
|
|
|
#include <drm/drm_mipi_dsi.h>
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include <drm/drm_dsc.h>
|
|
#include <drm/drm_print.h>
|
|
#include <video/mipi_display.h>
|
|
|
|
/**
|
|
* DOC: dsi helpers
|
|
*
|
|
* These functions contain some common logic and helpers to deal with MIPI DSI
|
|
* peripherals.
|
|
*
|
|
* Helpers are provided for a number of standard MIPI DSI command as well as a
|
|
* subset of the MIPI DCS command set.
|
|
*/
|
|
|
|
static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
|
|
{
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
/* attempt OF style match */
|
|
if (of_driver_match_device(dev, drv))
|
|
return 1;
|
|
|
|
/* compare DSI device and driver names */
|
|
if (!strcmp(dsi->name, drv->name))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int mipi_dsi_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|
{
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
int err;
|
|
|
|
err = of_device_uevent_modalias(dev, env);
|
|
if (err != -ENODEV)
|
|
return err;
|
|
|
|
add_uevent_var(env, "MODALIAS=%s%s", MIPI_DSI_MODULE_PREFIX,
|
|
dsi->name);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
|
|
.runtime_suspend = pm_generic_runtime_suspend,
|
|
.runtime_resume = pm_generic_runtime_resume,
|
|
.suspend = pm_generic_suspend,
|
|
.resume = pm_generic_resume,
|
|
.freeze = pm_generic_freeze,
|
|
.thaw = pm_generic_thaw,
|
|
.poweroff = pm_generic_poweroff,
|
|
.restore = pm_generic_restore,
|
|
};
|
|
|
|
static struct bus_type mipi_dsi_bus_type = {
|
|
.name = "mipi-dsi",
|
|
.match = mipi_dsi_device_match,
|
|
.uevent = mipi_dsi_uevent,
|
|
.pm = &mipi_dsi_device_pm_ops,
|
|
};
|
|
|
|
/**
|
|
* of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
|
|
* device tree node
|
|
* @np: device tree node
|
|
*
|
|
* Return: A pointer to the MIPI DSI device corresponding to @np or NULL if no
|
|
* such device exists (or has not been registered yet).
|
|
*/
|
|
struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np)
|
|
{
|
|
struct device *dev;
|
|
|
|
dev = bus_find_device_by_of_node(&mipi_dsi_bus_type, np);
|
|
|
|
return dev ? to_mipi_dsi_device(dev) : NULL;
|
|
}
|
|
EXPORT_SYMBOL(of_find_mipi_dsi_device_by_node);
|
|
|
|
static void mipi_dsi_dev_release(struct device *dev)
|
|
{
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
of_node_put(dev->of_node);
|
|
kfree(dsi);
|
|
}
|
|
|
|
static const struct device_type mipi_dsi_device_type = {
|
|
.release = mipi_dsi_dev_release,
|
|
};
|
|
|
|
static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host)
|
|
{
|
|
struct mipi_dsi_device *dsi;
|
|
|
|
dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
|
|
if (!dsi)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
dsi->host = host;
|
|
dsi->dev.bus = &mipi_dsi_bus_type;
|
|
dsi->dev.parent = host->dev;
|
|
dsi->dev.type = &mipi_dsi_device_type;
|
|
|
|
device_initialize(&dsi->dev);
|
|
|
|
return dsi;
|
|
}
|
|
|
|
static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
|
|
{
|
|
struct mipi_dsi_host *host = dsi->host;
|
|
|
|
dev_set_name(&dsi->dev, "%s.%d", dev_name(host->dev), dsi->channel);
|
|
|
|
return device_add(&dsi->dev);
|
|
}
|
|
|
|
#if IS_ENABLED(CONFIG_OF)
|
|
static struct mipi_dsi_device *
|
|
of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
|
|
{
|
|
struct mipi_dsi_device_info info = { };
|
|
int ret;
|
|
u32 reg;
|
|
|
|
if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
|
|
drm_err(host, "modalias failure on %pOF\n", node);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
ret = of_property_read_u32(node, "reg", ®);
|
|
if (ret) {
|
|
drm_err(host, "device node %pOF has no valid reg property: %d\n",
|
|
node, ret);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
info.channel = reg;
|
|
info.node = of_node_get(node);
|
|
|
|
return mipi_dsi_device_register_full(host, &info);
|
|
}
|
|
#else
|
|
static struct mipi_dsi_device *
|
|
of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
|
|
{
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* mipi_dsi_device_register_full - create a MIPI DSI device
|
|
* @host: DSI host to which this device is connected
|
|
* @info: pointer to template containing DSI device information
|
|
*
|
|
* Create a MIPI DSI device by using the device information provided by
|
|
* mipi_dsi_device_info template
|
|
*
|
|
* Returns:
|
|
* A pointer to the newly created MIPI DSI device, or, a pointer encoded
|
|
* with an error
|
|
*/
|
|
struct mipi_dsi_device *
|
|
mipi_dsi_device_register_full(struct mipi_dsi_host *host,
|
|
const struct mipi_dsi_device_info *info)
|
|
{
|
|
struct mipi_dsi_device *dsi;
|
|
int ret;
|
|
|
|
if (!info) {
|
|
drm_err(host, "invalid mipi_dsi_device_info pointer\n");
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
if (info->channel > 3) {
|
|
drm_err(host, "invalid virtual channel: %u\n", info->channel);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
dsi = mipi_dsi_device_alloc(host);
|
|
if (IS_ERR(dsi)) {
|
|
drm_err(host, "failed to allocate DSI device %ld\n",
|
|
PTR_ERR(dsi));
|
|
return dsi;
|
|
}
|
|
|
|
device_set_node(&dsi->dev, of_fwnode_handle(info->node));
|
|
dsi->channel = info->channel;
|
|
strlcpy(dsi->name, info->type, sizeof(dsi->name));
|
|
|
|
ret = mipi_dsi_device_add(dsi);
|
|
if (ret) {
|
|
drm_err(host, "failed to add DSI device %d\n", ret);
|
|
kfree(dsi);
|
|
return ERR_PTR(ret);
|
|
}
|
|
|
|
return dsi;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_device_register_full);
|
|
|
|
/**
|
|
* mipi_dsi_device_unregister - unregister MIPI DSI device
|
|
* @dsi: DSI peripheral device
|
|
*/
|
|
void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi)
|
|
{
|
|
device_unregister(&dsi->dev);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_device_unregister);
|
|
|
|
static DEFINE_MUTEX(host_lock);
|
|
static LIST_HEAD(host_list);
|
|
|
|
/**
|
|
* of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a
|
|
* device tree node
|
|
* @node: device tree node
|
|
*
|
|
* Returns:
|
|
* A pointer to the MIPI DSI host corresponding to @node or NULL if no
|
|
* such device exists (or has not been registered yet).
|
|
*/
|
|
struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
|
|
{
|
|
struct mipi_dsi_host *host;
|
|
|
|
mutex_lock(&host_lock);
|
|
|
|
list_for_each_entry(host, &host_list, list) {
|
|
if (host->dev->of_node == node) {
|
|
mutex_unlock(&host_lock);
|
|
return host;
|
|
}
|
|
}
|
|
|
|
mutex_unlock(&host_lock);
|
|
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
|
|
|
|
int mipi_dsi_host_register(struct mipi_dsi_host *host)
|
|
{
|
|
struct device_node *node;
|
|
|
|
for_each_available_child_of_node(host->dev->of_node, node) {
|
|
/* skip nodes without reg property */
|
|
if (!of_find_property(node, "reg", NULL))
|
|
continue;
|
|
of_mipi_dsi_device_add(host, node);
|
|
}
|
|
|
|
mutex_lock(&host_lock);
|
|
list_add_tail(&host->list, &host_list);
|
|
mutex_unlock(&host_lock);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_host_register);
|
|
|
|
static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
|
|
{
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
mipi_dsi_detach(dsi);
|
|
mipi_dsi_device_unregister(dsi);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void mipi_dsi_host_unregister(struct mipi_dsi_host *host)
|
|
{
|
|
device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn);
|
|
|
|
mutex_lock(&host_lock);
|
|
list_del_init(&host->list);
|
|
mutex_unlock(&host_lock);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_host_unregister);
|
|
|
|
/**
|
|
* mipi_dsi_attach - attach a DSI device to its DSI host
|
|
* @dsi: DSI peripheral
|
|
*/
|
|
int mipi_dsi_attach(struct mipi_dsi_device *dsi)
|
|
{
|
|
const struct mipi_dsi_host_ops *ops = dsi->host->ops;
|
|
|
|
if (!ops || !ops->attach)
|
|
return -ENOSYS;
|
|
|
|
return ops->attach(dsi->host, dsi);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_attach);
|
|
|
|
/**
|
|
* mipi_dsi_detach - detach a DSI device from its DSI host
|
|
* @dsi: DSI peripheral
|
|
*/
|
|
int mipi_dsi_detach(struct mipi_dsi_device *dsi)
|
|
{
|
|
const struct mipi_dsi_host_ops *ops = dsi->host->ops;
|
|
|
|
if (!ops || !ops->detach)
|
|
return -ENOSYS;
|
|
|
|
return ops->detach(dsi->host, dsi);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_detach);
|
|
|
|
static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi,
|
|
struct mipi_dsi_msg *msg)
|
|
{
|
|
const struct mipi_dsi_host_ops *ops = dsi->host->ops;
|
|
|
|
if (!ops || !ops->transfer)
|
|
return -ENOSYS;
|
|
|
|
if (dsi->mode_flags & MIPI_DSI_MODE_LPM)
|
|
msg->flags |= MIPI_DSI_MSG_USE_LPM;
|
|
msg->flags |= MIPI_DSI_MSG_LASTCOMMAND;
|
|
|
|
return ops->transfer(dsi->host, msg);
|
|
}
|
|
|
|
/**
|
|
* mipi_dsi_packet_format_is_short - check if a packet is of the short format
|
|
* @type: MIPI DSI data type of the packet
|
|
*
|
|
* Return: true if the packet for the given data type is a short packet, false
|
|
* otherwise.
|
|
*/
|
|
bool mipi_dsi_packet_format_is_short(u8 type)
|
|
{
|
|
switch (type) {
|
|
case MIPI_DSI_V_SYNC_START:
|
|
case MIPI_DSI_V_SYNC_END:
|
|
case MIPI_DSI_H_SYNC_START:
|
|
case MIPI_DSI_H_SYNC_END:
|
|
case MIPI_DSI_COMPRESSION_MODE:
|
|
case MIPI_DSI_END_OF_TRANSMISSION:
|
|
case MIPI_DSI_COLOR_MODE_OFF:
|
|
case MIPI_DSI_COLOR_MODE_ON:
|
|
case MIPI_DSI_SHUTDOWN_PERIPHERAL:
|
|
case MIPI_DSI_TURN_ON_PERIPHERAL:
|
|
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
|
|
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
|
|
case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
|
|
case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
|
|
case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
|
|
case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
|
|
case MIPI_DSI_DCS_SHORT_WRITE:
|
|
case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
|
|
case MIPI_DSI_DCS_READ:
|
|
case MIPI_DSI_EXECUTE_QUEUE:
|
|
case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_packet_format_is_short);
|
|
|
|
/**
|
|
* mipi_dsi_packet_format_is_long - check if a packet is of the long format
|
|
* @type: MIPI DSI data type of the packet
|
|
*
|
|
* Return: true if the packet for the given data type is a long packet, false
|
|
* otherwise.
|
|
*/
|
|
bool mipi_dsi_packet_format_is_long(u8 type)
|
|
{
|
|
switch (type) {
|
|
case MIPI_DSI_NULL_PACKET:
|
|
case MIPI_DSI_BLANKING_PACKET:
|
|
case MIPI_DSI_GENERIC_LONG_WRITE:
|
|
case MIPI_DSI_DCS_LONG_WRITE:
|
|
case MIPI_DSI_PICTURE_PARAMETER_SET:
|
|
case MIPI_DSI_COMPRESSED_PIXEL_STREAM:
|
|
case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_30:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_36:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_16:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_18:
|
|
case MIPI_DSI_PIXEL_STREAM_3BYTE_18:
|
|
case MIPI_DSI_PACKED_PIXEL_STREAM_24:
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_packet_format_is_long);
|
|
|
|
/**
|
|
* mipi_dsi_create_packet - create a packet from a message according to the
|
|
* DSI protocol
|
|
* @packet: pointer to a DSI packet structure
|
|
* @msg: message to translate into a packet
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
|
|
const struct mipi_dsi_msg *msg)
|
|
{
|
|
if (!packet || !msg)
|
|
return -EINVAL;
|
|
|
|
/* do some minimum sanity checking */
|
|
if (!mipi_dsi_packet_format_is_short(msg->type) &&
|
|
!mipi_dsi_packet_format_is_long(msg->type))
|
|
return -EINVAL;
|
|
|
|
if (msg->channel > 3)
|
|
return -EINVAL;
|
|
|
|
memset(packet, 0, sizeof(*packet));
|
|
packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f);
|
|
|
|
/* TODO: compute ECC if hardware support is not available */
|
|
|
|
/*
|
|
* Long write packets contain the word count in header bytes 1 and 2.
|
|
* The payload follows the header and is word count bytes long.
|
|
*
|
|
* Short write packets encode up to two parameters in header bytes 1
|
|
* and 2.
|
|
*/
|
|
if (mipi_dsi_packet_format_is_long(msg->type)) {
|
|
packet->header[1] = (msg->tx_len >> 0) & 0xff;
|
|
packet->header[2] = (msg->tx_len >> 8) & 0xff;
|
|
|
|
packet->payload_length = msg->tx_len;
|
|
packet->payload = msg->tx_buf;
|
|
} else {
|
|
const u8 *tx = msg->tx_buf;
|
|
|
|
packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0;
|
|
packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0;
|
|
}
|
|
|
|
packet->size = sizeof(packet->header) + packet->payload_length;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_create_packet);
|
|
|
|
/**
|
|
* mipi_dsi_shutdown_peripheral() - sends a Shutdown Peripheral command
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_SHUTDOWN_PERIPHERAL,
|
|
.tx_buf = (u8 [2]) { 0, 0 },
|
|
.tx_len = 2,
|
|
};
|
|
int ret = mipi_dsi_device_transfer(dsi, &msg);
|
|
|
|
return (ret < 0) ? ret : 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_shutdown_peripheral);
|
|
|
|
/**
|
|
* mipi_dsi_turn_on_peripheral() - sends a Turn On Peripheral command
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_TURN_ON_PERIPHERAL,
|
|
.tx_buf = (u8 [2]) { 0, 0 },
|
|
.tx_len = 2,
|
|
};
|
|
int ret = mipi_dsi_device_transfer(dsi, &msg);
|
|
|
|
return (ret < 0) ? ret : 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_turn_on_peripheral);
|
|
|
|
/*
|
|
* mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the
|
|
* the payload in a long packet transmitted from the peripheral back to the
|
|
* host processor
|
|
* @dsi: DSI peripheral device
|
|
* @value: the maximum size of the payload
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
|
|
u16 value)
|
|
{
|
|
u8 tx[2] = { value & 0xff, value >> 8 };
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
|
|
.tx_len = sizeof(tx),
|
|
.tx_buf = tx,
|
|
};
|
|
int ret = mipi_dsi_device_transfer(dsi, &msg);
|
|
|
|
return (ret < 0) ? ret : 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size);
|
|
|
|
/**
|
|
* mipi_dsi_compression_mode() - enable/disable DSC on the peripheral
|
|
* @dsi: DSI peripheral device
|
|
* @enable: Whether to enable or disable the DSC
|
|
*
|
|
* Enable or disable Display Stream Compression on the peripheral using the
|
|
* default Picture Parameter Set and VESA DSC 1.1 algorithm.
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable)
|
|
{
|
|
/* Note: Needs updating for non-default PPS or algorithm */
|
|
u8 tx[2] = { enable << 0, 0 };
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_COMPRESSION_MODE,
|
|
.tx_len = sizeof(tx),
|
|
.tx_buf = tx,
|
|
};
|
|
int ret = mipi_dsi_device_transfer(dsi, &msg);
|
|
|
|
return (ret < 0) ? ret : 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_compression_mode);
|
|
|
|
/**
|
|
* mipi_dsi_picture_parameter_set() - transmit the DSC PPS to the peripheral
|
|
* @dsi: DSI peripheral device
|
|
* @pps: VESA DSC 1.1 Picture Parameter Set
|
|
*
|
|
* Transmit the VESA DSC 1.1 Picture Parameter Set to the peripheral.
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi,
|
|
const struct drm_dsc_picture_parameter_set *pps)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_PICTURE_PARAMETER_SET,
|
|
.tx_len = sizeof(*pps),
|
|
.tx_buf = pps,
|
|
};
|
|
int ret = mipi_dsi_device_transfer(dsi, &msg);
|
|
|
|
return (ret < 0) ? ret : 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_picture_parameter_set);
|
|
|
|
/**
|
|
* mipi_dsi_generic_write() - transmit data using a generic write packet
|
|
* @dsi: DSI peripheral device
|
|
* @payload: buffer containing the payload
|
|
* @size: size of payload buffer
|
|
*
|
|
* This function will automatically choose the right data type depending on
|
|
* the payload length.
|
|
*
|
|
* Return: The number of bytes transmitted on success or a negative error code
|
|
* on failure.
|
|
*/
|
|
ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
|
|
size_t size)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.tx_buf = payload,
|
|
.tx_len = size
|
|
};
|
|
|
|
switch (size) {
|
|
case 0:
|
|
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
|
|
break;
|
|
|
|
case 1:
|
|
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
|
|
break;
|
|
|
|
case 2:
|
|
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
|
|
break;
|
|
|
|
default:
|
|
msg.type = MIPI_DSI_GENERIC_LONG_WRITE;
|
|
break;
|
|
}
|
|
|
|
return mipi_dsi_device_transfer(dsi, &msg);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_generic_write);
|
|
|
|
/**
|
|
* mipi_dsi_generic_read() - receive data using a generic read packet
|
|
* @dsi: DSI peripheral device
|
|
* @params: buffer containing the request parameters
|
|
* @num_params: number of request parameters
|
|
* @data: buffer in which to return the received data
|
|
* @size: size of receive buffer
|
|
*
|
|
* This function will automatically choose the right data type depending on
|
|
* the number of parameters passed in.
|
|
*
|
|
* Return: The number of bytes successfully read or a negative error code on
|
|
* failure.
|
|
*/
|
|
ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
|
|
size_t num_params, void *data, size_t size)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.tx_len = num_params,
|
|
.tx_buf = params,
|
|
.rx_len = size,
|
|
.rx_buf = data
|
|
};
|
|
|
|
switch (num_params) {
|
|
case 0:
|
|
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
|
|
break;
|
|
|
|
case 1:
|
|
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
|
|
break;
|
|
|
|
case 2:
|
|
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
|
|
break;
|
|
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
return mipi_dsi_device_transfer(dsi, &msg);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_generic_read);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload
|
|
* @dsi: DSI peripheral device
|
|
* @data: buffer containing data to be transmitted
|
|
* @len: size of transmission buffer
|
|
*
|
|
* This function will automatically choose the right data type depending on
|
|
* the command payload length.
|
|
*
|
|
* Return: The number of bytes successfully transmitted or a negative error
|
|
* code on failure.
|
|
*/
|
|
ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
|
|
const void *data, size_t len)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.tx_buf = data,
|
|
.tx_len = len
|
|
};
|
|
|
|
switch (len) {
|
|
case 0:
|
|
return -EINVAL;
|
|
|
|
case 1:
|
|
msg.type = MIPI_DSI_DCS_SHORT_WRITE;
|
|
break;
|
|
|
|
case 2:
|
|
msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
|
|
break;
|
|
|
|
default:
|
|
msg.type = MIPI_DSI_DCS_LONG_WRITE;
|
|
break;
|
|
}
|
|
|
|
return mipi_dsi_device_transfer(dsi, &msg);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_write() - send DCS write command
|
|
* @dsi: DSI peripheral device
|
|
* @cmd: DCS command
|
|
* @data: buffer containing the command payload
|
|
* @len: command payload length
|
|
*
|
|
* This function will automatically choose the right data type depending on
|
|
* the command payload length.
|
|
*
|
|
* Return: The number of bytes successfully transmitted or a negative error
|
|
* code on failure.
|
|
*/
|
|
ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
|
|
const void *data, size_t len)
|
|
{
|
|
ssize_t err;
|
|
size_t size;
|
|
u8 stack_tx[8];
|
|
u8 *tx;
|
|
|
|
size = 1 + len;
|
|
if (len > ARRAY_SIZE(stack_tx) - 1) {
|
|
tx = kmalloc(size, GFP_KERNEL);
|
|
if (!tx)
|
|
return -ENOMEM;
|
|
} else {
|
|
tx = stack_tx;
|
|
}
|
|
|
|
/* concatenate the DCS command byte and the payload */
|
|
tx[0] = cmd;
|
|
if (data)
|
|
memcpy(&tx[1], data, len);
|
|
|
|
err = mipi_dsi_dcs_write_buffer(dsi, tx, size);
|
|
|
|
if (tx != stack_tx)
|
|
kfree(tx);
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_write);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_read() - send DCS read request command
|
|
* @dsi: DSI peripheral device
|
|
* @cmd: DCS command
|
|
* @data: buffer in which to receive data
|
|
* @len: size of receive buffer
|
|
*
|
|
* Return: The number of bytes read or a negative error code on failure.
|
|
*/
|
|
ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
|
|
size_t len)
|
|
{
|
|
struct mipi_dsi_msg msg = {
|
|
.channel = dsi->channel,
|
|
.type = MIPI_DSI_DCS_READ,
|
|
.tx_buf = &cmd,
|
|
.tx_len = 1,
|
|
.rx_buf = data,
|
|
.rx_len = len
|
|
};
|
|
|
|
return mipi_dsi_device_transfer(dsi, &msg);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_read);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_nop() - send DCS nop packet
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_nop);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_soft_reset() - perform a software reset of the display module
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_get_power_mode() - query the display module's current power
|
|
* mode
|
|
* @dsi: DSI peripheral device
|
|
* @mode: return location for the current power mode
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode,
|
|
sizeof(*mode));
|
|
if (err <= 0) {
|
|
if (err == 0)
|
|
err = -ENODATA;
|
|
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
|
|
* data used by the interface
|
|
* @dsi: DSI peripheral device
|
|
* @format: return location for the pixel format
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format,
|
|
sizeof(*format));
|
|
if (err <= 0) {
|
|
if (err == 0)
|
|
err = -ENODATA;
|
|
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the
|
|
* display module except interface communication
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display
|
|
* module
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_display_off() - stop displaying the image data on the
|
|
* display device
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_display_on() - start displaying the image data on the
|
|
* display device
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure
|
|
*/
|
|
int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_column_address() - define the column extent of the frame
|
|
* memory accessed by the host processor
|
|
* @dsi: DSI peripheral device
|
|
* @start: first column of frame memory
|
|
* @end: last column of frame memory
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start,
|
|
u16 end)
|
|
{
|
|
u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff };
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload,
|
|
sizeof(payload));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_page_address() - define the page extent of the frame
|
|
* memory accessed by the host processor
|
|
* @dsi: DSI peripheral device
|
|
* @start: first page of frame memory
|
|
* @end: last page of frame memory
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
|
|
u16 end)
|
|
{
|
|
u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff };
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload,
|
|
sizeof(payload));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect
|
|
* output signal on the TE signal line
|
|
* @dsi: DSI peripheral device
|
|
*
|
|
* Return: 0 on success or a negative error code on failure
|
|
*/
|
|
int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect
|
|
* output signal on the TE signal line.
|
|
* @dsi: DSI peripheral device
|
|
* @mode: the Tearing Effect Output Line mode
|
|
*
|
|
* Return: 0 on success or a negative error code on failure
|
|
*/
|
|
int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
|
|
enum mipi_dsi_dcs_tear_mode mode)
|
|
{
|
|
u8 value = mode;
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value,
|
|
sizeof(value));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
|
|
* data used by the interface
|
|
* @dsi: DSI peripheral device
|
|
* @format: pixel format
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format,
|
|
sizeof(format));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_tear_scanline() - set the scanline to use as trigger for
|
|
* the Tearing Effect output signal of the display module
|
|
* @dsi: DSI peripheral device
|
|
* @scanline: scanline to use as trigger
|
|
*
|
|
* Return: 0 on success or a negative error code on failure
|
|
*/
|
|
int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
|
|
{
|
|
u8 payload[2] = { scanline >> 8, scanline & 0xff };
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_SCANLINE, payload,
|
|
sizeof(payload));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_display_brightness() - sets the brightness value of the
|
|
* display
|
|
* @dsi: DSI peripheral device
|
|
* @brightness: brightness value
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
|
|
u16 brightness)
|
|
{
|
|
u8 payload[2] = { brightness & 0xff, brightness >> 8 };
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
|
|
payload, sizeof(payload));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value
|
|
* of the display
|
|
* @dsi: DSI peripheral device
|
|
* @brightness: brightness value
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
|
u16 *brightness)
|
|
{
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
|
|
brightness, sizeof(*brightness));
|
|
if (err <= 0) {
|
|
if (err == 0)
|
|
err = -ENODATA;
|
|
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_set_display_brightness_large() - sets the 16-bit brightness value
|
|
* of the display
|
|
* @dsi: DSI peripheral device
|
|
* @brightness: brightness value
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi,
|
|
u16 brightness)
|
|
{
|
|
u8 payload[2] = { brightness >> 8, brightness & 0xff };
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
|
|
payload, sizeof(payload));
|
|
if (err < 0)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness_large);
|
|
|
|
/**
|
|
* mipi_dsi_dcs_get_display_brightness_large() - gets the current 16-bit
|
|
* brightness value of the display
|
|
* @dsi: DSI peripheral device
|
|
* @brightness: brightness value
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi,
|
|
u16 *brightness)
|
|
{
|
|
u8 brightness_be[2];
|
|
ssize_t err;
|
|
|
|
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
|
|
brightness_be, sizeof(brightness_be));
|
|
if (err <= 0) {
|
|
if (err == 0)
|
|
err = -ENODATA;
|
|
|
|
return err;
|
|
}
|
|
|
|
*brightness = (brightness_be[0] << 8) | brightness_be[1];
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness_large);
|
|
|
|
static int mipi_dsi_drv_probe(struct device *dev)
|
|
{
|
|
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
return drv->probe(dsi);
|
|
}
|
|
|
|
static int mipi_dsi_drv_remove(struct device *dev)
|
|
{
|
|
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
return drv->remove(dsi);
|
|
}
|
|
|
|
static void mipi_dsi_drv_shutdown(struct device *dev)
|
|
{
|
|
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
|
|
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
|
|
|
|
drv->shutdown(dsi);
|
|
}
|
|
|
|
/**
|
|
* mipi_dsi_driver_register_full() - register a driver for DSI devices
|
|
* @drv: DSI driver structure
|
|
* @owner: owner module
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
int mipi_dsi_driver_register_full(struct mipi_dsi_driver *drv,
|
|
struct module *owner)
|
|
{
|
|
drv->driver.bus = &mipi_dsi_bus_type;
|
|
drv->driver.owner = owner;
|
|
|
|
if (drv->probe)
|
|
drv->driver.probe = mipi_dsi_drv_probe;
|
|
if (drv->remove)
|
|
drv->driver.remove = mipi_dsi_drv_remove;
|
|
if (drv->shutdown)
|
|
drv->driver.shutdown = mipi_dsi_drv_shutdown;
|
|
|
|
return driver_register(&drv->driver);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_driver_register_full);
|
|
|
|
/**
|
|
* mipi_dsi_driver_unregister() - unregister a driver for DSI devices
|
|
* @drv: DSI driver structure
|
|
*
|
|
* Return: 0 on success or a negative error code on failure.
|
|
*/
|
|
void mipi_dsi_driver_unregister(struct mipi_dsi_driver *drv)
|
|
{
|
|
driver_unregister(&drv->driver);
|
|
}
|
|
EXPORT_SYMBOL(mipi_dsi_driver_unregister);
|
|
|
|
static int __init mipi_dsi_bus_init(void)
|
|
{
|
|
return bus_register(&mipi_dsi_bus_type);
|
|
}
|
|
postcore_initcall(mipi_dsi_bus_init);
|
|
|
|
MODULE_AUTHOR("Andrzej Hajda <a.hajda@samsung.com>");
|
|
MODULE_DESCRIPTION("MIPI DSI Bus");
|
|
MODULE_LICENSE("GPL and additional rights");
|