Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2012 Red Hat
0004  *
0005  * based in parts on udlfb.c:
0006  * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
0007  * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
0008  * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
0009  */
0010 
0011 #ifndef UDL_DRV_H
0012 #define UDL_DRV_H
0013 
0014 #include <linux/mm_types.h>
0015 #include <linux/usb.h>
0016 
0017 #include <drm/drm_device.h>
0018 #include <drm/drm_framebuffer.h>
0019 #include <drm/drm_gem.h>
0020 #include <drm/drm_simple_kms_helper.h>
0021 
0022 struct drm_mode_create_dumb;
0023 
0024 #define DRIVER_NAME     "udl"
0025 #define DRIVER_DESC     "DisplayLink"
0026 #define DRIVER_DATE     "20120220"
0027 
0028 #define DRIVER_MAJOR        0
0029 #define DRIVER_MINOR        0
0030 #define DRIVER_PATCHLEVEL   1
0031 
0032 struct udl_device;
0033 
0034 struct urb_node {
0035     struct list_head entry;
0036     struct udl_device *dev;
0037     struct delayed_work release_urb_work;
0038     struct urb *urb;
0039 };
0040 
0041 struct urb_list {
0042     struct list_head list;
0043     spinlock_t lock;
0044     struct semaphore limit_sem;
0045     int available;
0046     int count;
0047     size_t size;
0048 };
0049 
0050 struct udl_device {
0051     struct drm_device drm;
0052     struct device *dev;
0053     struct device *dmadev;
0054 
0055     struct drm_simple_display_pipe display_pipe;
0056 
0057     struct mutex gem_lock;
0058 
0059     int sku_pixel_limit;
0060 
0061     struct urb_list urbs;
0062 
0063     char mode_buf[1024];
0064     uint32_t mode_buf_len;
0065 };
0066 
0067 #define to_udl(x) container_of(x, struct udl_device, drm)
0068 
0069 static inline struct usb_device *udl_to_usb_device(struct udl_device *udl)
0070 {
0071     return interface_to_usbdev(to_usb_interface(udl->drm.dev));
0072 }
0073 
0074 /* modeset */
0075 int udl_modeset_init(struct drm_device *dev);
0076 struct drm_connector *udl_connector_init(struct drm_device *dev);
0077 
0078 struct urb *udl_get_urb(struct drm_device *dev);
0079 
0080 int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
0081 void udl_urb_completion(struct urb *urb);
0082 
0083 int udl_init(struct udl_device *udl);
0084 
0085 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
0086              const char *front, char **urb_buf_ptr,
0087              u32 byte_offset, u32 device_byte_offset, u32 byte_width);
0088 
0089 int udl_drop_usb(struct drm_device *dev);
0090 
0091 #define CMD_WRITE_RAW8   "\xAF\x60" /**< 8 bit raw write command. */
0092 #define CMD_WRITE_RL8    "\xAF\x61" /**< 8 bit run length command. */
0093 #define CMD_WRITE_COPY8  "\xAF\x62" /**< 8 bit copy command. */
0094 #define CMD_WRITE_RLX8   "\xAF\x63" /**< 8 bit extended run length command. */
0095 
0096 #define CMD_WRITE_RAW16  "\xAF\x68" /**< 16 bit raw write command. */
0097 #define CMD_WRITE_RL16   "\xAF\x69" /**< 16 bit run length command. */
0098 #define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */
0099 #define CMD_WRITE_RLX16  "\xAF\x6B" /**< 16 bit extended run length command. */
0100 
0101 /* On/Off for driving the DisplayLink framebuffer to the display */
0102 #define UDL_REG_BLANK_MODE      0x1f
0103 
0104 #define UDL_BLANK_MODE_ON       0x00 /* hsync and vsync on, visible */
0105 #define UDL_BLANK_MODE_BLANKED      0x01 /* hsync and vsync on, blanked */
0106 #define UDL_BLANK_MODE_VSYNC_OFF    0x03 /* vsync off, blanked */
0107 #define UDL_BLANK_MODE_HSYNC_OFF    0x05 /* hsync off, blanked */
0108 #define UDL_BLANK_MODE_POWERDOWN    0x07 /* powered off; requires modeset */
0109 
0110 #endif