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
15 #include <video_osd.h>
18 static int do_osd_write(struct cmd_tbl *cmdtp, int flag, int argc,
29 if (argc < 4 || (strlen(argv[3])) % 2)
32 x = hextoul(argv[1], NULL);
33 y = hextoul(argv[2], NULL);
35 count = (argc > 4) ? hextoul(argv[4], NULL) : 1;
37 buflen = strlen(hexstr) / 2;
39 buffer = malloc(buflen);
41 puts("Memory allocation failure\n");
42 return CMD_RET_FAILURE;
45 res = hex2bin(buffer, hexstr, buflen);
48 puts("Hexadecimal input contained invalid characters\n");
49 return CMD_RET_FAILURE;
52 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
54 uclass_next_device(&dev)) {
57 res = video_osd_set_mem(dev, x, y, buffer, buflen, count);
60 printf("Could not write to video mem on osd %s\n",
62 return CMD_RET_FAILURE;
68 return CMD_RET_SUCCESS;
71 static int do_osd_print(struct cmd_tbl *cmdtp, int flag, int argc,
82 x = hextoul(argv[1], NULL);
83 y = hextoul(argv[2], NULL);
84 color = hextoul(argv[3], NULL);
87 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
89 uclass_next_device(&dev)) {
92 res = video_osd_print(dev, x, y, color, text);
94 printf("Could not print string to osd %s\n", dev->name);
95 return CMD_RET_FAILURE;
99 return CMD_RET_SUCCESS;
102 static int do_osd_size(struct cmd_tbl *cmdtp, int flag, int argc,
109 return CMD_RET_USAGE;
111 x = hextoul(argv[1], NULL);
112 y = hextoul(argv[2], NULL);
114 for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
116 uclass_next_device(&dev)) {
119 res = video_osd_set_size(dev, x, y);
122 printf("Could not set size on osd %s\n", dev->name);
123 return CMD_RET_FAILURE;
127 return CMD_RET_SUCCESS;
131 osdw, 5, 0, do_osd_write,
132 "write 16-bit hex encoded buffer to osd memory",
133 "osdw [pos_x] [pos_y] [buffer] [count] - write 8-bit hex encoded buffer to osd memory\n"
137 osdp, 5, 0, do_osd_print,
138 "write ASCII buffer to osd memory",
139 "osdp [pos_x] [pos_y] [color] [text] - write ASCII buffer to osd memory\n"
143 osdsize, 3, 0, do_osd_size,
144 "set OSD XY size in characters",
145 "osdsize [size_x] [size_y] - set OSD XY size in characters\n"