drm/udl: Add constants for commands

Add constants for the various commands that the driver can send to
the device and update the respective helper functions. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221006095355.23579-17-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2022-10-06 11:53:55 +02:00
Родитель 44f29ad9a4
Коммит 1b8db07f23
4 изменённых файлов: 28 добавлений и 20 удалений

Просмотреть файл

@ -102,14 +102,4 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
int udl_drop_usb(struct drm_device *dev); int udl_drop_usb(struct drm_device *dev);
int udl_select_std_channel(struct udl_device *udl); int udl_select_std_channel(struct udl_device *udl);
#define CMD_WRITE_RAW8 "\xAF\x60" /**< 8 bit raw write command. */
#define CMD_WRITE_RL8 "\xAF\x61" /**< 8 bit run length command. */
#define CMD_WRITE_COPY8 "\xAF\x62" /**< 8 bit copy command. */
#define CMD_WRITE_RLX8 "\xAF\x63" /**< 8 bit extended run length command. */
#define CMD_WRITE_RAW16 "\xAF\x68" /**< 16 bit raw write command. */
#define CMD_WRITE_RL16 "\xAF\x69" /**< 16 bit run length command. */
#define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */
#define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */
#endif #endif

Просмотреть файл

@ -29,15 +29,17 @@
#include "udl_proto.h" #include "udl_proto.h"
/* /*
* All DisplayLink bulk operations start with 0xAF, followed by specific code * All DisplayLink bulk operations start with 0xaf (UDL_MSG_BULK), followed by
* All operations are written to buffers which then later get sent to device * a specific command code. All operations are written to a command buffer, which
* the driver sends to the device.
*/ */
static char *udl_set_register(char *buf, u8 reg, u8 val) static char *udl_set_register(char *buf, u8 reg, u8 val)
{ {
*buf++ = 0xAF; *buf++ = UDL_MSG_BULK;
*buf++ = 0x20; *buf++ = UDL_CMD_WRITEREG;
*buf++ = reg; *buf++ = reg;
*buf++ = val; *buf++ = val;
return buf; return buf;
} }
@ -179,8 +181,8 @@ static char *udl_set_display_mode(char *buf, struct drm_display_mode *mode)
static char *udl_dummy_render(char *wrptr) static char *udl_dummy_render(char *wrptr)
{ {
*wrptr++ = 0xAF; *wrptr++ = UDL_MSG_BULK;
*wrptr++ = 0x6A; /* copy */ *wrptr++ = UDL_CMD_WRITECOPY16;
*wrptr++ = 0x00; /* from addr */ *wrptr++ = 0x00; /* from addr */
*wrptr++ = 0x00; *wrptr++ = 0x00;
*wrptr++ = 0x00; *wrptr++ = 0x00;
@ -235,7 +237,7 @@ static int udl_handle_damage(struct drm_framebuffer *fb,
/* Send partial buffer remaining before exiting */ /* Send partial buffer remaining before exiting */
int len; int len;
if (cmd < (char *)urb->transfer_buffer + urb->transfer_buffer_length) if (cmd < (char *)urb->transfer_buffer + urb->transfer_buffer_length)
*cmd++ = 0xAF; *cmd++ = UDL_MSG_BULK;
len = cmd - (char *)urb->transfer_buffer; len = cmd - (char *)urb->transfer_buffer;
ret = udl_submit_urb(dev, urb, len); ret = udl_submit_urb(dev, urb, len);
} else { } else {

Просмотреть файл

@ -5,6 +5,21 @@
#include <linux/bits.h> #include <linux/bits.h>
#define UDL_MSG_BULK 0xaf
/* Register access */
#define UDL_CMD_WRITEREG 0x20 /* See register constants below */
/* Framebuffer access */
#define UDL_CMD_WRITERAW8 0x60 /* 8 bit raw write command. */
#define UDL_CMD_WRITERL8 0x61 /* 8 bit run length command. */
#define UDL_CMD_WRITECOPY8 0x62 /* 8 bit copy command. */
#define UDL_CMD_WRITERLX8 0x63 /* 8 bit extended run length command. */
#define UDL_CMD_WRITERAW16 0x68 /* 16 bit raw write command. */
#define UDL_CMD_WRITERL16 0x69 /* 16 bit run length command. */
#define UDL_CMD_WRITECOPY16 0x6a /* 16 bit copy command. */
#define UDL_CMD_WRITERLX16 0x6b /* 16 bit extended run length command. */
/* Color depth */ /* Color depth */
#define UDL_REG_COLORDEPTH 0x00 #define UDL_REG_COLORDEPTH 0x00
#define UDL_COLORDEPTH_16BPP 0 #define UDL_COLORDEPTH_16BPP 0

Просмотреть файл

@ -10,6 +10,7 @@
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include "udl_drv.h" #include "udl_drv.h"
#include "udl_proto.h"
#define MAX_CMD_PIXELS 255 #define MAX_CMD_PIXELS 255
@ -89,8 +90,8 @@ static void udl_compress_hline16(
const u8 *cmd_pixel_start, *cmd_pixel_end = NULL; const u8 *cmd_pixel_start, *cmd_pixel_end = NULL;
uint16_t pixel_val16; uint16_t pixel_val16;
*cmd++ = 0xaf; *cmd++ = UDL_MSG_BULK;
*cmd++ = 0x6b; *cmd++ = UDL_CMD_WRITERLX16;
*cmd++ = (uint8_t) ((dev_addr >> 16) & 0xFF); *cmd++ = (uint8_t) ((dev_addr >> 16) & 0xFF);
*cmd++ = (uint8_t) ((dev_addr >> 8) & 0xFF); *cmd++ = (uint8_t) ((dev_addr >> 8) & 0xFF);
*cmd++ = (uint8_t) ((dev_addr) & 0xFF); *cmd++ = (uint8_t) ((dev_addr) & 0xFF);
@ -152,7 +153,7 @@ static void udl_compress_hline16(
if (cmd_buffer_end <= MIN_RLX_CMD_BYTES + cmd) { if (cmd_buffer_end <= MIN_RLX_CMD_BYTES + cmd) {
/* Fill leftover bytes with no-ops */ /* Fill leftover bytes with no-ops */
if (cmd_buffer_end > cmd) if (cmd_buffer_end > cmd)
memset(cmd, 0xAF, cmd_buffer_end - cmd); memset(cmd, UDL_MSG_BULK, cmd_buffer_end - cmd);
cmd = (uint8_t *) cmd_buffer_end; cmd = (uint8_t *) cmd_buffer_end;
} }