驱动层代码
static int __ite_ioctl(struct file *filp,unsigned int cmd,unsigned long arg )
{
printk("__ite_ioctl \n");
switch (cmd)
{
//获取垂直分辨率
case IT6604_IO_GET_RES:
{
arg=(unsigned long)&__hdmi_info;
printk("<%4d,%4d> \n",(int)__hdmi_info.h_active, (int)__hdmi_info.v_active);
break;
}
default:
break;
}
}用户层代码
int main(void)
{
int fd = 0;
__input_info hdmi_info;
fd = open("/dev/myit6604",O_RDONLY);
if(fd < 0)
{
printf("open file error \n");
return -1;
}
if(ioctl(fd, IT6604_IO_READ,&hdmi_info) < 0)
{
printf("error\n");
return -1;
}
printf("<%d,%d> \n",(int)hdmi_info.h_res,(int)hdmi_info.v_res);
close(fd);
return 0;
}执行用户程序的代码后结果
此时分辨率为1080P的
mnt/demo/ioctrl # ./a.out
<0,72>
/mnt/demo/ioctrl # ./a.out
<0,72>
static int __ite_ioctl(struct file *filp,unsigned int cmd,unsigned long arg )
{
printk("__ite_ioctl \n");
switch (cmd)
{
//获取垂直分辨率
case IT6604_IO_GET_RES:
{
arg=(unsigned long)&__hdmi_info;
printk("<%4d,%4d> \n",(int)__hdmi_info.h_active, (int)__hdmi_info.v_active);
break;
}
default:
break;
}
}用户层代码
int main(void)
{
int fd = 0;
__input_info hdmi_info;
fd = open("/dev/myit6604",O_RDONLY);
if(fd < 0)
{
printf("open file error \n");
return -1;
}
if(ioctl(fd, IT6604_IO_READ,&hdmi_info) < 0)
{
printf("error\n");
return -1;
}
printf("<%d,%d> \n",(int)hdmi_info.h_res,(int)hdmi_info.v_res);
close(fd);
return 0;
}执行用户程序的代码后结果
此时分辨率为1080P的
mnt/demo/ioctrl # ./a.out
<0,72>
/mnt/demo/ioctrl # ./a.out
<0,72>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货