Hi,
I got a task to write a driver for ISP that is connected via PCI.
I started to read the book:“Developing Drivers with the Windows Driver Foundation”, the MSDN documentation and found that I should concentrate on PLX9x5x and avstream samples.
I first started with PLX9x5x (I generally get the concept ) , but I don’t know how to change or use the sample to get start writing my own driver , how to configure the evtdevicepreparehardware and other function , do they differ from pci device to pci device?
Any suggestion would be much appreciated.
Best regards.
Yes, functions like EvtDevicePrepareHardware need to be specific to your
device. While the overall logic will be similar across drivers your device
will have a certain number of BAR’s and things like where to store the base
address of these BAR’s and what to do if you don’t see all the resources you
expect, are dependent on your device.
The book you refer to has some excellent illustrations mapping out the order
in which calls for starting up and shutting down a device occur, you need to
understand this. For the device itself, you need to understand the actions
needed for setup, shutdown and the various operations and put them into the
framework.
Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Thursday, September 25, 2014 8:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Writing driver for ISP(image signal processor)
Hi,
I got a task to write a driver for ISP that is connected via PCI.
I started to read the book:“Developing Drivers with the Windows Driver
Foundation”, the MSDN documentation and found that I should concentrate on
PLX9x5x and avstream samples.
I first started with PLX9x5x (I generally get the concept ) , but I don’t
know how to change or use the sample to get start writing my own driver ,
how to configure the evtdevicepreparehardware and other function , do they
differ from pci device to pci device?
Any suggestion would be much appreciated.
Best regards.
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
xxxxx@hotmail.com wrote:
I got a task to write a driver for ISP that is connected via PCI.
I started to read the book:“Developing Drivers with the Windows Driver Foundation”, the MSDN documentation and found that I should concentrate on PLX9x5x and avstream samples.
I first started with PLX9x5x (I generally get the concept ) , but I don’t know how to change or use the sample to get start writing my own driver , how to configure the evtdevicepreparehardware and other function , do they differ from pci device to pci device?
One of the key questions you need to ask is “what kind of a driver do I
need?” You said you’re driving an Image Signal Processor. That can
mean a dozen different things. How will it be used? Does it need to
participate in DirectShow streams or Media Foundation topologies? If
so, then it will need to be an AVStream driver, and you should be
looking at the AVStream samples. Or will it be a complete custom
interface to some custom application? Do you need to do DMA?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
It will be used for stream. The ISP is a part of a SoC. We are also looking at the AVStream mini-driver for connection with DirectShow(later also to a custom app). But I think I need the device driver for the pci connection between the cpu and the isp, and do the DMA (scatter gather thing that is simulated in the AVstream sample).
xxxxx@hotmail.com wrote:
It will be used for stream. The ISP is a part of a SoC. We are also looking at the AVStream mini-driver for connection with DirectShow (later also to a custom app). But I think I need the device driver for the pci connection between the cpu and the isp, and do the DMA (scatter gather thing that is simulated in the AVstream sample).
You SEEM to be thinking that you need two different drivers. That’s not
the case. If you need your hardware to be exposed as an AVStream
device, then you will write an AVStream driver that does DMA.
ALL drivers essentially act as a translator between some language on the
top (facing applications), and some language on the bottom (facing
hardware). You don’t just write a driver for a device. You write a
driver that offers some specific services – the language on top.
In your case, you need a driver that speaks PCI on the bottom. You’ll
do direct register writes and configure and manage DMA. Your driver
will speak Kernel Streaming on the top, to offer streaming services.
That is an AVStream driver.
Now, in some specialized circumstances, you might want to have two
drivers: one that talks to PCI on the bottom and offers some custom
internal interface on the top, and then an AVStream driver that talks to
your custom internal interface on the bottom. That would only be needed
if you expected to need specialized access to the device outside of the
streaming APIs.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Hi Tim,
I think I need two drivers because I need to write/read to device registers (ISP PCI Configuration Registers, ISP Memory Mapped IO Registers [Intel Atom]), load a firmware(I tihnk this should be done in the bottom driver in the EvtDeviceD0Entry?), do the dma. Is the PLX9x5x a god start point to this?
I have also an linux driver for the ISP (poorly documented), do You maybe have some advice how to use it to easier do the win drv ?
Now the AVStream needs to talk to the pci drv with IOCTL? And the app(user mod) talks to the AVStream with Kernel Streaming api?
This sounds like one driver to me…
IF you need interrupts on your device to facilitate the loading of the firmware, you’ll want to do this in “EvtDeviceD0EntryPostInterruptsEnabled”
Poorly documented? For Linux? On GitHub? I shocked! But, you know, all the source code is there, so you should be all set (sarcasm).
I’m sorry… the bad news is that we tend not to “port” drivers from Linux… we tend to “rewrite” them. The models can be very different. The good news is that the Linux driver will at least show you precisely how you can interact with the hardware to make it work. That can be *very* helpful.
Peter
OSR
@OSRDrivers
xxxxx@hotmail.com wrote:
I think I need two drivers because I need to write/read to device registers (ISP PCI Configuration Registers, ISP Memory Mapped IO Registers [Intel Atom]), load a firmware(I tihnk this should be done in the bottom driver in the EvtDeviceD0Entry?), do the dma.
Your AVStream driver can do anything that your proposed lower-level
driver can do. Why do you think they need to be separate? If you need
to write a register, then you write a register.
The only consideration is that your AVStream driver will not be KMDF.
You’ll be handling things in the AVStream callbacks instead of the KMDF
callbacks. The AVStream port driver already provides much of the
framework that KMDF provides. It is possible to use KMDF in an AVStream
driver in “miniport mode”, but you would still be getting your requests
in the AVStream callbacks.
So, instead of EvtDeviceD0Entry, you’d handle things in the
DevicePnpStart callback, or in the AcquireHardwareResources function
that the AVStream samples demonstrate.
Is the PLX9x5x a god start point to this?
I had written up an answer to this, but after looking the source code
you provided, I have to change my answer. The PLX9x5x shows how to do
DMA to a PCI device using KMDF. You have none of those things. This is
not a PCI device. This is a MIPI camera, built-in to an Intel Atom SoC.
What versions of Windows were you hoping to support with this?
I have also an linux driver for the ISP (poorly documented), do You maybe have some advice how to use it to easier do the win drv ?
Video4Linux2 has a very different architecture from AVStream. The Linux
source will help you know which registers to write and in which order,
but that’s about it.
However, there’s much more to it than that. There is no native MIPI
support in Windows, because there is no standard way to connect a MIPI
device to an Intel processor. MIPI is an electrical interface, not a
protocol. This is all new, all custom. You have an ENORMOUS job ahead
of you. If you have close cooperation from Intel help, you might be
able to get this done in 6 months. If you don’t have a close
relationship with Intel’s team, I’d go so far as to assert that you will
not be able to do this.
Now the AVStream needs to talk to the pci drv with IOCTL? And the app(user mod) talks to the AVStream with Kernel Streaming api?
The AVStream driver can talk to the device. No separate driver is
needed. The app will use DirectShow. DirectShow will talk to AVStream
using the Kernel Streaming APIs.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
>> Is the PLX9x5x a god start point to this?
I had written up an answer to this, but after looking the source code
you provided, I have to change my answer. The PLX9x5x shows how to do
DMA to a PCI device using KMDF. You have none of those things. This is
not a PCI device. This is a MIPI camera, built-in to an Intel Atom SoC.
In datasheet of intel atom: http://www.intel.com/content/www/us/en/intelligent-systems/bay-trail/atom-e3800-family-datasheet.html
page 884 -> Camera, ISP are connected to PCi space
page 885 -> ISP PCI configuration registers
page 911 -> Memmapped IO
Dma will be used to copy the “image” from sensor(camera) to RAM, ISP has an build in dma.
What versions of Windows were you hoping to support with this?
win 8.1 , win 7
It is gonna be probably one driver but AVStream is god example of streaming and PLX9x5x is PCI and DMA but how to combine them ?
xxxxx@hotmail.com wrote:
>> Is the PLX9x5x a god start point to this?
…
Dma will be used to copy the “image” from sensor(camera) to RAM, ISP has an build in dma.
Sort of. It’s not clear to me that this is “DMA” in the same sense as
the PLX9x5x. If you can extract that information out of the 707 pages
in that document dedicated to the MIPI/ISP interface, you’re a better
man than I.
It is gonna be probably one driver but AVStream is god example of streaming and PLX9x5x is PCI and DMA but how to combine them ?
You’re still not thinking about this in the right way. You don’t just
write “an AVStream driver” or “a PCI driver” or “a USB driver”. When
you have an AVStream driver, you have to DRIVE something. If you have a
USB device that is a web camera, you write an AVStream driver that talks
to USB. If you have a PCI device that is a video camera, you write an
AVStream driver that talks to PCI.
As I tried to explain before, every driver has a TOP interface and a
BOTTOM interface. For a USB web cam driver, like usbvideo.sys, it’s
like this:
| AVStream
±-------------+
| usbvideo.sys |
±-------------+
| USB
A PCI-based USB host controller speaks USB requests at the top, and
talks to PCI at the bottom:
| USB
±-------------+
| usbehci.sys |
±-------------+
| PCI
Your driver will look like this (mostly):
| AVStream
±---------------+
| yourdriver.sys |
±---------------+
| PCI
If you wrote this as two separate drivers, how would you communicate
between them? You’d have to invent an artificial interface that did
nothing but add complexity and cost performance.
The AVStream samples have a “fake” device at the bottom end, to simulate
the hardware that would ordinarily be accessed . You will replace that
fake device with real PCI register accesses. You look at the things
that are expected from an AVStream driver, and you write code that
satisfies each of those things from your hardware.
I want to caution you AGAIN not to underestimate this task. This device
has more than 1,000 registers, and the documentation is nearly useless.
Because it is embedded inside the Atom chip, any kind of hardware-level
debugging will be impossible.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Hi pei zhang,
Intel support the ISP (lenovo thinkpad 8 http://support.lenovo.com/us/en/downloads/ds040016), but they have only few supported image sensors (consumer) , but not ours.
They are not easy to give the source code so that we can integrate our camera sensor and our needs thus we have to write it, or may be You have a better solution?
Best Regards.
Thanks Tim for Your time.
Yes it is only one driver, now I understand.
Your driver will look like this (mostly):
| AVStream
±---------------+
| yourdriver.sys |
±---------------+
| PCI
Question: so to communicate from myDriver to PCI ( PCI Bus driver?), is the code in TOASTER ->KMDF->BUS->STATIC exampled for this and this documet http://msdn.microsoft.com/en-us/library/windows/hardware/ff536890(v=vs.85).aspx ?
Best Regards
xxxxx@hotmail.com wrote:
Intel support the ISP (lenovo thinkpad 8 http://support.lenovo.com/us/en/downloads/ds040016), but they have only few supported image sensors (consumer) , but not ours.
They are not easy to give the source code so that we can integrate our camera sensor and our needs thus we have to write it, or may be You have a better solution?
Working with Intel is the better solution. This is a large and very
complicated interface. Until they release an SDK of some kind, or
create an OEM program for it, it will be much quicker for your upper
management to have happy meetings with Intel’s management and convince
them to partner with you.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
xxxxx@hotmail.com wrote:
Question: so to communicate from myDriver to PCI ( PCI Bus driver?), is the code in TOASTER ->KMDF->BUS->STATIC exampled for this and this documet http://msdn.microsoft.com/en-us/library/windows/hardware/ff536890(v=vs.85).aspx ?
If you need access to the PCI configuration space, then yes, you will
use the interface you posted. For the memory-mapped registers, the
resources will be handed to your EvtAddDevice callback, where you’ll map
them into virtual memory.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.