1 // SPDX-License-Identifier: GPL-2.0+
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
6 * based on the gdsys osd driver, which is
9 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
16 #include <video_osd.h>
19 static int do_osd_write(struct cmd_tbl *cmdtp, int flag, int argc,
30 if (argc < 4 || (strlen(argv[3])) % 2)
33 x = simple_strtoul(argv[1], NULL, 16);
34 y = simple_strtoul(argv[2], NULL, 16);
36 count = (argc > 4) ? simple_strtoul(argv[4], NULL, 16) : 1;
38 buflen = strlen(hexstr) / 2;
40 buffer = malloc(buflen);
42 puts("Memory allocation failure\n");
43 return CMD_RET_FAILURE;
46 res = hex2bin(buffer, hexstr, buflen);
49 puts("Hexadecimal input contained invalid characters\n");
50 return CMD_RET_FAILURE;
53 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
55 uclass_next_device(&dev)) {
58 res = video_osd_set_mem(dev, x, y, buffer, buflen, count);
61 printf("Could not write to video mem on osd %s\n",
63 return CMD_RET_FAILURE;
69 return CMD_RET_SUCCESS;
72 static int do_osd_print(struct cmd_tbl *cmdtp, int flag, int argc,
83 x = simple_strtoul(argv[1], NULL, 16);
84 y = simple_strtoul(argv[2], NULL, 16);
85 color = simple_strtoul(argv[3], NULL, 16);
88 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
90 uclass_next_device(&dev)) {
93 res = video_osd_print(dev, x, y, color, text);
95 printf("Could not print string to osd %s\n", dev->name);
96 return CMD_RET_FAILURE;
100 return CMD_RET_SUCCESS;
103 static int do_osd_size(struct cmd_tbl *cmdtp, int flag, int argc,
110 return CMD_RET_USAGE;
112 x = simple_strtoul(argv[1], NULL, 16);
113 y = simple_strtoul(argv[2], NULL, 16);
115 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
117 uclass_next_device(&dev)) {
120 res = video_osd_set_size(dev, x, y);
123 printf("Could not set size on osd %s\n", dev->name);
124 return CMD_RET_FAILURE;
128 return CMD_RET_SUCCESS;
132 osdw, 5, 0, do_osd_write,
133 "write 16-bit hex encoded buffer to osd memory",
134 "osdw [pos_x] [pos_y] [buffer] [count] - write 8-bit hex encoded buffer to osd memory\n"
138 osdp, 5, 0, do_osd_print,
139 "write ASCII buffer to osd memory",
140 "osdp [pos_x] [pos_y] [color] [text] - write ASCII buffer to osd memory\n"
144 osdsize, 3, 0, do_osd_size,
145 "set OSD XY size in characters",
146 "osdsize [size_x] [size_y] - set OSD XY size in characters\n"