vdr
1.7.27
|
00001 /********************************************************************** 00002 * 00003 * HDFF firmware command interface library 00004 * 00005 * Copyright (C) 2011 Andreas Regel 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the 00019 * Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 *********************************************************************/ 00023 00024 #include <stdint.h> 00025 #include <string.h> 00026 #include <sys/ioctl.h> 00027 00028 #include "hdffcmd.h" 00029 #include "hdffcmd_base.h" 00030 #include "hdffcmd_defs.h" 00031 00032 int HdffCmdGetFirmwareVersion(int OsdDevice, uint32_t * Version, char * String, 00033 uint32_t MaxLength) 00034 { 00035 uint8_t cmdData[8]; 00036 uint8_t resultData[64]; 00037 BitBuffer_t cmdBuf; 00038 osd_raw_cmd_t osd_cmd; 00039 int err; 00040 00041 *Version = 0; 00042 String[0] = 0; 00043 00044 BitBuffer_Init(&cmdBuf, cmdData, sizeof(cmdData)); 00045 memset(&osd_cmd, 0, sizeof(osd_raw_cmd_t)); 00046 osd_cmd.cmd_data = cmdData; 00047 osd_cmd.result_data = resultData; 00048 osd_cmd.result_len = sizeof(resultData); 00049 HdffCmdBuildHeader(&cmdBuf, HDFF_MSG_TYPE_COMMAND, HDFF_MSG_GROUP_GENERIC, 00050 HDFF_MSG_GEN_GET_FIRMWARE_VERSION); 00051 osd_cmd.cmd_len = HdffCmdSetLength(&cmdBuf); 00052 err = ioctl(OsdDevice, OSD_RAW_CMD, &osd_cmd); 00053 if (err == 0) 00054 { 00055 if (osd_cmd.result_len > 0) 00056 { 00057 uint8_t textLength = resultData[9]; 00058 if (textLength >= MaxLength) 00059 textLength = MaxLength - 1; 00060 memcpy(String, &resultData[10], textLength); 00061 String[textLength] = 0; 00062 *Version = (resultData[6] << 16) 00063 | (resultData[7] << 8) 00064 | resultData[8]; 00065 } 00066 } 00067 return err; 00068 } 00069 00070 int HdffCmdGetInterfaceVersion(int OsdDevice, uint32_t * Version, char * String, 00071 uint32_t MaxLength) 00072 { 00073 uint8_t cmdData[8]; 00074 uint8_t resultData[64]; 00075 BitBuffer_t cmdBuf; 00076 osd_raw_cmd_t osd_cmd; 00077 int err; 00078 00079 *Version = 0; 00080 String[0] = 0; 00081 00082 BitBuffer_Init(&cmdBuf, cmdData, sizeof(cmdData)); 00083 memset(&osd_cmd, 0, sizeof(osd_raw_cmd_t)); 00084 osd_cmd.cmd_data = cmdData; 00085 osd_cmd.result_data = resultData; 00086 osd_cmd.result_len = sizeof(resultData); 00087 HdffCmdBuildHeader(&cmdBuf, HDFF_MSG_TYPE_COMMAND, HDFF_MSG_GROUP_GENERIC, 00088 HDFF_MSG_GEN_GET_INTERFACE_VERSION); 00089 osd_cmd.cmd_len = HdffCmdSetLength(&cmdBuf); 00090 err = ioctl(OsdDevice, OSD_RAW_CMD, &osd_cmd); 00091 if (err == 0) 00092 { 00093 if (osd_cmd.result_len > 0) 00094 { 00095 uint8_t textLength = resultData[9]; 00096 if (textLength >= MaxLength) 00097 textLength = MaxLength - 1; 00098 memcpy(String, &resultData[10], textLength); 00099 String[textLength] = 0; 00100 *Version = (resultData[6] << 16) 00101 | (resultData[7] << 8) 00102 | resultData[8]; 00103 } 00104 } 00105 return err; 00106 } 00107 00108 int HdffCmdGetCopyrights(int OsdDevice, uint8_t Index, char * String, 00109 uint32_t MaxLength) 00110 { 00111 uint8_t cmdData[8]; 00112 uint8_t resultData[280]; 00113 BitBuffer_t cmdBuf; 00114 osd_raw_cmd_t osd_cmd; 00115 int err; 00116 00117 String[0] = 0; 00118 00119 BitBuffer_Init(&cmdBuf, cmdData, sizeof(cmdData)); 00120 memset(&osd_cmd, 0, sizeof(osd_raw_cmd_t)); 00121 osd_cmd.cmd_data = cmdData; 00122 osd_cmd.result_data = resultData; 00123 osd_cmd.result_len = sizeof(resultData); 00124 HdffCmdBuildHeader(&cmdBuf, HDFF_MSG_TYPE_COMMAND, HDFF_MSG_GROUP_GENERIC, 00125 HDFF_MSG_GEN_GET_COPYRIGHTS); 00126 BitBuffer_SetBits(&cmdBuf, 8, Index); 00127 osd_cmd.cmd_len = HdffCmdSetLength(&cmdBuf); 00128 err = ioctl(OsdDevice, OSD_RAW_CMD, &osd_cmd); 00129 if (err == 0) 00130 { 00131 if (osd_cmd.result_len > 0) 00132 { 00133 uint8_t index = resultData[6]; 00134 uint8_t textLen = resultData[7]; 00135 if (index == Index && textLen > 0) 00136 { 00137 if (textLen >= MaxLength) 00138 { 00139 textLen = MaxLength - 1; 00140 } 00141 memcpy(String, resultData + 8, textLen); 00142 String[textLen] = 0; 00143 } 00144 } 00145 } 00146 return err; 00147 }