ioctl

amba H2平台用PWM控制LCD背光

守給你的承諾、 提交于 2019-12-02 19:02:06
amba H2系列CPU的GPIO口能作PWM使用的个数有限(GPIO0-GPIO3),从PRM里GPIO: Function Selection章节可以得到如何配置GPIO为PWM功能。 假设想把GPIO0配置成PWM输出,根据上图修改ambarella/boards/h2_xxx/bsp/bsp.h ,如下: 即DEFAULT_IOMUX_REG0_2、DEFAULT_IOMUX_REG0_1、DEFAULT_IOMUX_REG0_0的第0位要分别设为0、1、1。 一、系统层用脚本控制PWM0示例 echo 0 > /sys/class/pwm/pwmchip0/export echo 5000000 > /sys/class/pwm/pwmchip0/pwm0/period (设置周期) echo 2000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle (设置有效时间) echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable (使能PWM) 占空比= 有效时间/周期, 占空比越大,LCD背光越亮(有效时间要小于等于周期时间)。 为了方便使用写成脚本set_pwm.sh: #! /bin/bash # # set_pwm.sh <gpio_id> < 1 | 0 > <duty_cycle>

audio write pcm ioctl - SNDRV_PCM_IOCTL_WRITEI_FRAMES

痴心易碎 提交于 2019-12-02 12:50:09
http://androidxref.com/9.0.0_r3/xref/external/tinyalsa/pcm.c#535 http://androidxref.com/kernel_3.18/xref/sound/core/pcm_native.c#2745 https://blog.csdn.net/Vincentywj/article/details/77849442 对于回放的情形,PCM 数据流向大致是: copy_from_user DMA I2S DAC ^ ^ ^ ^ +---------+ | +----------+ | +-----------+ | +-----+ | +------+ |userspace+-------->DMA Buffer+------->I2S TX FIFO+------->CODEC+------->SPK/HP| +---------+ +----------+ +-----------+ +-----+ +------+ 来源: https://blog.csdn.net/chenqiang0721/article/details/102761326

Enumerate all network interfaces with IPs on FreeBSD

落花浮王杯 提交于 2019-12-02 07:18:50
问题 My application needs to list all network interafaces on a machine and their IPs, IPv4 and IPv6. I can get all interfaces with IPv4 IPs using ioctl(SIOCGIFCONF), but I need the IPv6 IPs, too. On Linux, those can get gotten from /proc/net/if_inet6, but where would I get them on FreeBSD ? 回答1: getifaddrs(3) provides portable way to get network addresses and interface names. 来源: https://stackoverflow.com/questions/7629164/enumerate-all-network-interfaces-with-ips-on-freebsd

Enumerate all network interfaces with IPs on FreeBSD

时间秒杀一切 提交于 2019-12-02 07:02:17
My application needs to list all network interafaces on a machine and their IPs, IPv4 and IPv6. I can get all interfaces with IPv4 IPs using ioctl(SIOCGIFCONF), but I need the IPv6 IPs, too. On Linux, those can get gotten from /proc/net/if_inet6, but where would I get them on FreeBSD ? getifaddrs(3) provides portable way to get network addresses and interface names. 来源: https://stackoverflow.com/questions/7629164/enumerate-all-network-interfaces-with-ips-on-freebsd

C# Union Structure Marshalling

拜拜、爱过 提交于 2019-12-02 01:08:11
问题 I'm trying to integrate Video4Linux in my managed application. Indeed I've declared all required structures and relative ioctl . In this question I present two ioctl : SetFormat and GetFormat ; while the former is working well (like the other dozen I actually use), the latter is returning me bad memory behavior. The GetFormat ioctl is actually performing, but as soon the application is accessing to the ioctl parameter (either debugger or my application itself), it always crashes with

Can't change terminal size on pty/N (works on ttyN)

独自空忆成欢 提交于 2019-12-01 23:20:26
问题 I use the next to change terminal size: rc = ioctl(fd, TIOCSWINSZ, &ws); When I run this under linux text terminal (switching by Alt-Ctrl-F1), the result is that I expect to see. The whole my input and output within ranges given by ioctl syscall. But when I connect to localhost by SSH, and run the same program, it works only partly. I mean that I can't input command wider than terminal size set by ioctl, but the output can cross the borders of terminal given by ioctl, and input can take more

C# Union Structure Marshalling

痞子三分冷 提交于 2019-12-01 21:00:33
I'm trying to integrate Video4Linux in my managed application. Indeed I've declared all required structures and relative ioctl . In this question I present two ioctl : SetFormat and GetFormat ; while the former is working well (like the other dozen I actually use), the latter is returning me bad memory behavior. The GetFormat ioctl is actually performing, but as soon the application is accessing to the ioctl parameter (either debugger or my application itself), it always crashes with following stack: System.NullReferenceException: ... at System.String.mempy4(...) in <filename unknown>:0 at

tcp与串口透传

ⅰ亾dé卋堺 提交于 2019-12-01 05:29:31
介绍 tcp作为服务端,监听端口8888,实现串口透传,这里是使用select监听tcp的receive和串口的read,单工通信 程序 #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <linux/serial.h> #include <sys/ioctl.h> #include <sys/select.h> #include <termios.h> void Test_err(int flg) { if(flg<0) { perror(strerror(errno)); exit(1); } } int main(int argc, char** argv) { printf("usage : %s <port,default is 8888>\n",argv[0]); printf("tcp-server...enter\n"); unsigned char* uart_port="/dev

When pty [Pseudo terminal] slave fd settings are changed by “tcsetattr” , how can the master end capture this event without delay?

跟風遠走 提交于 2019-12-01 05:15:18
The slave fd is used by another application (say "A") as a serial port device . A will set its baud rate/stop bit etc. My app needs this information . BTW, is there any way for a process that has only the master fd open to be notified of all ioctl() calls that are issued to the slave fd ? Yes, this is possible (in Linux and pre-2004 FreeBSD) , using the pty in packet mode and setting the EXTPROC flag on it. Packet mode is enabled on the master end by ioctl(master, TIOCPKT, &nonzero) . Now every read on the master end will yield a packet : whatever was written on the other side, plus a status

When pty [Pseudo terminal] slave fd settings are changed by “tcsetattr” , how can the master end capture this event without delay?

烈酒焚心 提交于 2019-12-01 02:54:27
问题 The slave fd is used by another application (say "A") as a serial port device . A will set its baud rate/stop bit etc. My app needs this information . BTW, is there any way for a process that has only the master fd open to be notified of all ioctl() calls that are issued to the slave fd ? 回答1: Yes, this is possible (in Linux and pre-2004 FreeBSD) , using the pty in packet mode and setting the EXTPROC flag on it. Packet mode is enabled on the master end by ioctl(master, TIOCPKT, &nonzero) .