Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | // SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2017 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc * * based on the gdsys osd driver, which is * * (C) Copyright 2010 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de */ #include <command.h> #include <dm.h> #include <hexdump.h> #include <video_osd.h> #include <malloc.h> static int do_osd_write(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; uint x, y; uint count; char *hexstr; u8 *buffer; size_t buflen; int res; if (argc < 4 || (strlen(argv[3])) % 2) return CMD_RET_USAGE; x = hextoul(argv[1], NULL); y = hextoul(argv[2], NULL); hexstr = argv[3]; count = (argc > 4) ? hextoul(argv[4], NULL) : 1; buflen = strlen(hexstr) / 2; buffer = malloc(buflen); if (!buffer) { puts("Memory allocation failure\n"); return CMD_RET_FAILURE; } res = hex2bin(buffer, hexstr, buflen); if (res) { free(buffer); puts("Hexadecimal input contained invalid characters\n"); return CMD_RET_FAILURE; } for (uclass_first_device(UCLASS_VIDEO_OSD, &dev); dev; uclass_next_device(&dev)) { int res; res = video_osd_set_mem(dev, x, y, buffer, buflen, count); if (res) { free(buffer); printf("Could not write to video mem on osd %s\n", dev->name); return CMD_RET_FAILURE; } } free(buffer); return CMD_RET_SUCCESS; } static int do_osd_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; uint x, y; u8 color; char *text; if (argc < 5) return CMD_RET_USAGE; x = hextoul(argv[1], NULL); y = hextoul(argv[2], NULL); color = hextoul(argv[3], NULL); text = argv[4]; for (uclass_first_device(UCLASS_VIDEO_OSD, &dev); dev; uclass_next_device(&dev)) { int res; res = video_osd_print(dev, x, y, color, text); if (res) { printf("Could not print string to osd %s\n", dev->name); return CMD_RET_FAILURE; } } return CMD_RET_SUCCESS; } static int do_osd_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; uint x, y; if (argc < 3) return CMD_RET_USAGE; x = hextoul(argv[1], NULL); y = hextoul(argv[2], NULL); for (uclass_first_device(UCLASS_VIDEO_OSD, &dev); dev; uclass_next_device(&dev)) { int res; res = video_osd_set_size(dev, x, y); if (res) { printf("Could not set size on osd %s\n", dev->name); return CMD_RET_FAILURE; } } return CMD_RET_SUCCESS; } U_BOOT_CMD( osdw, 5, 0, do_osd_write, "write 16-bit hex encoded buffer to osd memory", "osdw [pos_x] [pos_y] [buffer] [count] - write 8-bit hex encoded buffer to osd memory\n" ); U_BOOT_CMD( osdp, 5, 0, do_osd_print, "write ASCII buffer to osd memory", "osdp [pos_x] [pos_y] [color] [text] - write ASCII buffer to osd memory\n" ); U_BOOT_CMD( osdsize, 3, 0, do_osd_size, "set OSD XY size in characters", "osdsize [size_x] [size_y] - set OSD XY size in characters\n" ); |