18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012 Red Hat 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * based in parts on udlfb.c: 68c2ecf20Sopenharmony_ci * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it> 78c2ecf20Sopenharmony_ci * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com> 88c2ecf20Sopenharmony_ci * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef UDL_DRV_H 128c2ecf20Sopenharmony_ci#define UDL_DRV_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 158c2ecf20Sopenharmony_ci#include <linux/usb.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 188c2ecf20Sopenharmony_ci#include <drm/drm_framebuffer.h> 198c2ecf20Sopenharmony_ci#include <drm/drm_gem.h> 208c2ecf20Sopenharmony_ci#include <drm/drm_simple_kms_helper.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct drm_mode_create_dumb; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define DRIVER_NAME "udl" 258c2ecf20Sopenharmony_ci#define DRIVER_DESC "DisplayLink" 268c2ecf20Sopenharmony_ci#define DRIVER_DATE "20120220" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define DRIVER_MAJOR 0 298c2ecf20Sopenharmony_ci#define DRIVER_MINOR 0 308c2ecf20Sopenharmony_ci#define DRIVER_PATCHLEVEL 1 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct udl_device; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct urb_node { 358c2ecf20Sopenharmony_ci struct list_head entry; 368c2ecf20Sopenharmony_ci struct udl_device *dev; 378c2ecf20Sopenharmony_ci struct delayed_work release_urb_work; 388c2ecf20Sopenharmony_ci struct urb *urb; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct urb_list { 428c2ecf20Sopenharmony_ci struct list_head list; 438c2ecf20Sopenharmony_ci spinlock_t lock; 448c2ecf20Sopenharmony_ci struct semaphore limit_sem; 458c2ecf20Sopenharmony_ci int available; 468c2ecf20Sopenharmony_ci int count; 478c2ecf20Sopenharmony_ci size_t size; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct udl_device { 518c2ecf20Sopenharmony_ci struct drm_device drm; 528c2ecf20Sopenharmony_ci struct device *dev; 538c2ecf20Sopenharmony_ci struct device *dmadev; 548c2ecf20Sopenharmony_ci struct usb_device *udev; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci struct drm_simple_display_pipe display_pipe; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci struct mutex gem_lock; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci int sku_pixel_limit; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci struct urb_list urbs; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci char mode_buf[1024]; 658c2ecf20Sopenharmony_ci uint32_t mode_buf_len; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define to_udl(x) container_of(x, struct udl_device, drm) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* modeset */ 718c2ecf20Sopenharmony_ciint udl_modeset_init(struct drm_device *dev); 728c2ecf20Sopenharmony_cistruct drm_connector *udl_connector_init(struct drm_device *dev); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistruct urb *udl_get_urb(struct drm_device *dev); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciint udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len); 778c2ecf20Sopenharmony_civoid udl_urb_completion(struct urb *urb); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciint udl_init(struct udl_device *udl); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciint udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, 828c2ecf20Sopenharmony_ci const char *front, char **urb_buf_ptr, 838c2ecf20Sopenharmony_ci u32 byte_offset, u32 device_byte_offset, u32 byte_width); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciint udl_drop_usb(struct drm_device *dev); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define CMD_WRITE_RAW8 "\xAF\x60" /**< 8 bit raw write command. */ 888c2ecf20Sopenharmony_ci#define CMD_WRITE_RL8 "\xAF\x61" /**< 8 bit run length command. */ 898c2ecf20Sopenharmony_ci#define CMD_WRITE_COPY8 "\xAF\x62" /**< 8 bit copy command. */ 908c2ecf20Sopenharmony_ci#define CMD_WRITE_RLX8 "\xAF\x63" /**< 8 bit extended run length command. */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define CMD_WRITE_RAW16 "\xAF\x68" /**< 16 bit raw write command. */ 938c2ecf20Sopenharmony_ci#define CMD_WRITE_RL16 "\xAF\x69" /**< 16 bit run length command. */ 948c2ecf20Sopenharmony_ci#define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */ 958c2ecf20Sopenharmony_ci#define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */ 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* On/Off for driving the DisplayLink framebuffer to the display */ 988c2ecf20Sopenharmony_ci#define UDL_REG_BLANK_MODE 0x1f 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define UDL_BLANK_MODE_ON 0x00 /* hsync and vsync on, visible */ 1018c2ecf20Sopenharmony_ci#define UDL_BLANK_MODE_BLANKED 0x01 /* hsync and vsync on, blanked */ 1028c2ecf20Sopenharmony_ci#define UDL_BLANK_MODE_VSYNC_OFF 0x03 /* vsync off, blanked */ 1038c2ecf20Sopenharmony_ci#define UDL_BLANK_MODE_HSYNC_OFF 0x05 /* hsync off, blanked */ 1048c2ecf20Sopenharmony_ci#define UDL_BLANK_MODE_POWERDOWN 0x07 /* powered off; requires modeset */ 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#endif 107