xuesong.jiang | 1c26548 | 2023-04-03 07:22:20 +0000 | [diff] [blame^] | 1 | /* GStreamer |
| 2 | * Copyright (C) 2023 <xuesong.jiang@amlogic.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public |
| 15 | * License along with this library; if not, write to the |
| 16 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include <unistd.h> |
| 21 | #include <fcntl.h> |
| 22 | #include <stdio.h> |
| 23 | |
| 24 | static int set_osd_blank(int blank) |
| 25 | { |
| 26 | const char *path1 = "/sys/class/graphics/fb0/blank"; |
| 27 | const char *path3 = "/sys/class/graphics/fb0/osd_display_debug"; |
| 28 | int fd; |
| 29 | char cmd[128] = {0}; |
| 30 | |
| 31 | fd = open(path3, O_CREAT | O_RDWR | O_TRUNC, 0644); |
| 32 | if (fd >= 0) |
| 33 | { |
| 34 | sprintf(cmd, "%d", blank); |
| 35 | write(fd, cmd, strlen(cmd)); |
| 36 | close(fd); |
| 37 | } |
| 38 | fd = open(path1, O_CREAT | O_RDWR | O_TRUNC, 0644); |
| 39 | if (fd >= 0) |
| 40 | { |
| 41 | sprintf(cmd, "%d", blank); |
| 42 | write(fd, cmd, strlen(cmd)); |
| 43 | close(fd); |
| 44 | } |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | static int amsysfs_set_sysfs_str(const char *path, const char *val) |
| 49 | { |
| 50 | int fd; |
| 51 | fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644); |
| 52 | if (fd >= 0) |
| 53 | { |
| 54 | write(fd, val, strlen(val)); |
| 55 | close(fd); |
| 56 | return 0; |
| 57 | } |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | static int set_dmx_source() |
| 62 | { |
| 63 | amsysfs_set_sysfs_str("/sys/class/stb/source", "dmx0"); |
| 64 | amsysfs_set_sysfs_str("/sys/class/stb/demux0_source", "hiu"); |
| 65 | return 0; |
| 66 | } |