Hi
I have connected a LVDS display in I2C in BayTrail platform and loaded the I/O driver provided in Intel website. Also, i have followed the steps mentioned in the user manual (Software Developers Manual for Windows 7 IO Driver.pdf ) provided along with driver.
I have written a application based on the Intel document to write the EDID values but it shows Error code 2 (ERROR_FILE_NOT_FOUND) when i call the DeviceIoControl.
I have used the sample code provided in the amcc5933 sample application (OpenDevice function) in the WinDDK and the handle is valid.
Could you please provide your help on this issue?
I have copied the OpenDevice and DeviceIoControl funtion source code:
int main ( void )
{
int i = 0;
I2C_SEQUENCE_TRANSMISSION_ENTRY(2) sequence;
I2C_SINGLE_TRANSMISSION writeTransmission;
BOOL status;
HANDLE hPCIdevice;
OVERLAPPED Overlapped1;
int bytesReturned;
unsigned short regAddr = 0x0000;
//UCHAR readBuf[BUF_SIZE] = {};
unsigned short slaveAdr = 0x1c;
unsigned int delayInUs = 100;
UCHAR writeBuf[2] = {0x77, 0x99};
sequence.Size = 2;
hPCIdevice = OpenDevice(&I2C_LPSS_INTERFACE_GUID,
FILE_FLAG_OVERLAPPED );
if (hPCIdevice == INVALID_HANDLE_VALUE) {
puts("(PCI) Can't open device");
exit(1);
}
printf("The LVDS device interface is opened, 0x%x\r\n",hPCIdevice);
//OVERLAPPED Overlapped1;
/*Overlapped1.OffsetHigh = 0;
Overlapped1.Offset = 0;*/
memset(&Overlapped1, 0, sizeof(Overlapped1));
writeTransmission.Address = slaveAdr;
writeTransmission.AddressMode = AddressMode7Bit;
writeTransmission.BusSpeed = I2C_BUS_SPEED_400KHZ;
writeTransmission.DataLength = sizeof(writeBuf);
writeTransmission.pBuffer = writeBuf;
status = DeviceIoControl(
hPCIdevice,
IOCTL_I2C_EXECUTE_WRITE,
&writeTransmission,
sizeof(writeTransmission),
NULL,
0,
NULL,
&Overlapped1);
printf("status = 0x%d error = 0x%x",status, GetLastError() );
if(status || (GetLastError() == ERROR_IO_PENDING))
{
status = GetOverlappedResult(
hPCIdevice,
&Overlapped1,
&bytesReturned,TRUE);
if(status)
{
/****
* Now data in writeBuf have been transmitted to slave device.
****/
printf("Write is passed\r\n");
}
else
printf("error = 0x%x",GetLastError() );
}
CloseHandle(hPCIdevice);
return 1;
} // end main()
HANDLE
OpenDevice(
IN CONST GUID * InterfaceGuid,
IN ULONG FileFlagOptions
)
{
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
SP_DEVINFO_DATA DeviceInfoData;
HDEVINFO hDevInfo;
PSP_DEVICE_INTERFACE_DETAIL_DATA pDeviceInterfaceDetail = NULL;
HANDLE hDevice;
ULONG size;
int count, i, index;
BOOL status = TRUE;
TCHAR *DeviceName = NULL;
TCHAR *DeviceLocation = NULL;
//
// Retreive the device information for all DSC devices.
//
hDevInfo = SetupDiGetClassDevs(InterfaceGuid,
NULL,
NULL,
DIGCF_DEVICEINTERFACE |
DIGCF_PRESENT );
if(INVALID_HANDLE_VALUE == hDevInfo) {
printf("No devices are present and enabled in the system\n");
return INVALID_HANDLE_VALUE;
}
//
// Initialize the SP_DEVICE_INTERFACE_DATA Structure.
//
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
//
// Determine how many devices are present.
//
count = 0;
while(SetupDiEnumDeviceInterfaces(hDevInfo,
NULL,
InterfaceGuid,
count++, //Cycle through the available devices.
&DeviceInterfaceData));
//
// Since the last call fails when all devices have been enumerated,
// decrement the count to get the true device count.
//
count--;
//
// If the count is zero then there are no devices present.
//
if(count == 0)
{
printf("No devices are present and enabled in the system.\n");
goto End;
}
//
// Initialize the appropriate data structures in preparation for
// the SetupDi calls.
//
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
//
// Loop through the device list to allow user to choose
// a device. If there is only one device, select it
// by default.
//
i = 0;
while(SetupDiEnumDeviceInterfaces(hDevInfo,
NULL,
(LPGUID)InterfaceGuid,
i,
&DeviceInterfaceData))
{
//
// Determine the size required for the DeviceInterfaceData
//
SetupDiGetDeviceInterfaceDetail(hDevInfo,
&DeviceInterfaceData,
NULL,
0,
&size,
NULL);
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d", GetLastError());
goto End;
}
pDeviceInterfaceDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
if(!pDeviceInterfaceDetail)
{
printf("Insufficient memory.\n");
goto End;
}
//
// Initialize structure and retrieve data.
//
pDeviceInterfaceDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
status = SetupDiGetDeviceInterfaceDetail(hDevInfo,
&DeviceInterfaceData,
pDeviceInterfaceDetail,
size,
NULL,
&DeviceInfoData);
free(pDeviceInterfaceDetail);
pDeviceInterfaceDetail = NULL;
if(!status)
{
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d", GetLastError());
goto End;
}
//
// Get the Device Name
// Calls to SetupDiGetDeviceRegistryProperty require two consecutive
// calls, first to get required buffer size and second to get
// the data.
//
SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
NULL,
(PBYTE)DeviceName,
0,
&size);
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
printf("SetupDiGetDeviceRegistryProperty failed, Error: %d", GetLastError());
goto End;
}
DeviceName = (TCHAR*) malloc(size);
if(!DeviceName)
{
printf("Insufficient memory.\n");
goto End;
}
status = SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
NULL,
(PBYTE)DeviceName,
size,
NULL);
if(!status)
{
printf("SetupDiGetDeviceRegistryProperty failed, Error: %d", GetLastError());
free(DeviceName);
goto End;
}
//
// Now retrieve the Device Location.
//
SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_LOCATION_INFORMATION,
NULL,
(PBYTE)DeviceLocation,
0,
&size);
if(GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
DeviceLocation = (TCHAR*) malloc(size);
if (DeviceLocation != NULL)
{
status = SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_LOCATION_INFORMATION,
NULL,
(PBYTE)DeviceLocation,
size,
NULL);
if(!status)
{
free(DeviceLocation);
DeviceLocation = NULL;
}
}
} else {
DeviceLocation = NULL;
}
//
// If there is more than one device print description.
//
if(count > 1)
{
printf("%d- ", i);
}
printf("%s\n", DeviceName);
if(DeviceLocation)
{
printf(" %s\n", DeviceLocation);
}
free(DeviceName);
free(DeviceLocation);
i++; // Cycle through the available devices.
}
//
// Select device.
//
index = 0;
if(count > 1)
{
printf("\nSelect Device: ");
(void)scanf_s("%d", &index);
}
//
// Get information for specific device.
//
status = SetupDiEnumDeviceInterfaces(hDevInfo,
NULL,
(LPGUID)InterfaceGuid,
index,
&DeviceInterfaceData);
if(!status)
{
printf("SetupDiEnumDeviceInterfaces failed, Error: %d", GetLastError());
goto End;
}
//
// Determine the size required for the DeviceInterfaceData
//
SetupDiGetDeviceInterfaceDetail(hDevInfo,
&DeviceInterfaceData,
NULL,
0,
&size,
NULL);
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d", GetLastError());
goto End;
}
pDeviceInterfaceDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
if(!pDeviceInterfaceDetail)
{
printf("Insufficient memory.\n");
goto End;
}
//
// Initialize structure and retrieve data.
//
pDeviceInterfaceDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
status = SetupDiGetDeviceInterfaceDetail(hDevInfo,
&DeviceInterfaceData,
pDeviceInterfaceDetail,
size,
NULL,
&DeviceInfoData);
if(!status)
{
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d", GetLastError());
goto End;
}
//
// Get handle to device.
//
hDevice = CreateFile(pDeviceInterfaceDetail->DevicePath,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FileFlagOptions,
NULL
);
if(hDevice == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed. Error:%d", GetLastError());
}
free(pDeviceInterfaceDetail);
SetupDiDestroyDeviceInfoList(hDevInfo);
return hDevice;
End:
if(pDeviceInterfaceDetail) {
free(pDeviceInterfaceDetail);
}
SetupDiDestroyDeviceInfoList(hDevInfo);
return INVALID_HANDLE_VALUE;
}
Thanks