Static int __ite_ioctl (struct file * filp, unsigned int CMD, unsigned long arg)
{
Printk (" __ite_ioctl \ n ");
The switch (CMD)
{
//for vertical resolution
Case IT6604_IO_GET_RES:
{
Args=(unsigned long) & amp; __hdmi_info;
Printk (" & lt; % % 4 d, 4 d & gt; . \ n ", (int) __hdmi_info h_active, (int) __hdmi_info. V_active);
break;
}
Default:
break;
}
}
The user layer code
Int main (void)
{
Int fd=0;
__input_info hdmi_info;
Fd=open ("/dev/myit6604 ", O_RDONLY);
If (fd & lt; 0)
{
Printf (" open file error \ n ");
return -1;
}
If (ioctl (fd, IT6604_IO_READ, & amp; Hdmi_info) & lt; 0)
{
Printf (" error "\ n");
return -1;
}
Printf (" & lt; % d, % d> . \ n ", (int) hdmi_info h_res, (int) hdmi_info. V_res);
Close (fd);
return 0;
}
Implement the user program code after the results
The resolution of 1080 p
MNT/demo/ioctrl #./a.out
<0 regulation & gt;
/MNT/demo/ioctrl #./a.out
<0 regulation & gt;
CodePudding user response:
Kernel state and application state interactive data should use the copy_from_user and copy_to_user, one more thing, why don't ioctl command code, two command code names, definitions are the same,CodePudding user response:
Command code is right, is not the same as the macro definition, kernel and application states interactive data if will use the copy_from_user and copy_to_use efficiency slow, I looked at a lot of examples are use the copy_from_user and copy_to_useCodePudding user response:
Command code is right, is not the same as the macro definition, kernel and application states interactive data if will use the copy_from_user and copy_to_use efficiency slow, I looked at a lot of examples are use the copy_from_user and copy_to_useCodePudding user response: