codec/codec_h_ctrl.c
Go to the documentation of this file.00001 00008 /* Copyright (C) 2007-2011, Amlogic Inc. 00009 * All right reserved 00010 * 00011 */ 00012 #include <stdio.h> 00013 00014 #include <sys/types.h> 00015 #include <sys/stat.h> 00016 #include <errno.h> 00017 #include <sys/ioctl.h> 00018 #include <fcntl.h> 00019 #include <sys/mman.h> 00020 #include <codec_error.h> 00021 #include <codec.h> 00022 #include "codec_h_ctrl.h" 00023 00024 /* --------------------------------------------------------------------------*/ 00033 /* --------------------------------------------------------------------------*/ 00034 CODEC_HANDLE codec_h_open(const char *port_addr, int flags) 00035 { 00036 int r; 00037 r = open(port_addr, flags); 00038 if (r < 0) { 00039 CODEC_PRINT("Init [%s] failed,ret = %d\n", port_addr, r); 00040 return r; 00041 } 00042 return (CODEC_HANDLE)r; 00043 } 00044 00045 /* --------------------------------------------------------------------------*/ 00053 /* --------------------------------------------------------------------------*/ 00054 CODEC_HANDLE codec_h_open_rd(const char *port_addr) 00055 { 00056 int r; 00057 r = open(port_addr, O_RDONLY); 00058 if (r < 0) { 00059 CODEC_PRINT("Init [%s] failed,ret = %d\n", port_addr, r); 00060 return r; 00061 } 00062 return (CODEC_HANDLE)r; 00063 } 00064 00065 /* --------------------------------------------------------------------------*/ 00073 /* --------------------------------------------------------------------------*/ 00074 int codec_h_close(CODEC_HANDLE h) 00075 { 00076 if (h >= 0) { 00077 close(h); 00078 } 00079 return 0; 00080 } 00081 00082 /* --------------------------------------------------------------------------*/ 00092 /* --------------------------------------------------------------------------*/ 00093 int codec_h_control(CODEC_HANDLE h, int cmd, unsigned long paramter) 00094 { 00095 int r; 00096 00097 if (h < 0) { 00098 return -1; 00099 } 00100 r = ioctl(h, cmd, paramter); 00101 if (r < 0) { 00102 CODEC_PRINT("send control failed,handle=%d,cmd=%x,paramter=%x, t=%x\n", h, cmd, paramter, r); 00103 return r; 00104 } 00105 return 0; 00106 } 00107 00108 /* --------------------------------------------------------------------------*/ 00118 /* --------------------------------------------------------------------------*/ 00119 int codec_h_read(CODEC_HANDLE handle, void *buffer, int size) 00120 { 00121 int r; 00122 r = read(handle, buffer, size); 00123 return r; 00124 } 00125 00126 /* --------------------------------------------------------------------------*/ 00136 /* --------------------------------------------------------------------------*/ 00137 int codec_h_write(CODEC_HANDLE handle, void *buffer, int size) 00138 { 00139 int r; 00140 r = write(handle, buffer, size); 00141 return r; 00142 } 00143 00144 00145
Generated on Fri Feb 25 15:30:29 2011 for Amcodec by 1.6.1