1 / 28

Developing WIA Drivers Byron Changuion Developer Windows Imaging Group Microsoft Corporation

Developing WIA Drivers Byron Changuion Developer Windows Imaging Group Microsoft Corporation. Preamble. What is this presentation about? Selected topics regarding development of WIA mini-drivers (“full” WIA drivers) This talk is not necessary for you, if your device is:

Download Presentation

Developing WIA Drivers Byron Changuion Developer Windows Imaging Group Microsoft Corporation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing WIA DriversByron ChanguionDeveloperWindows Imaging GroupMicrosoft Corporation

  2. Preamble • What is this presentation about? • Selected topics regarding development of WIA mini-drivers (“full” WIA drivers) • This talk is not necessary for you, if your device is: • PTP camera or Mass Storage device • Class driver exists • Simple flatbed scanner • Can write “micro-driver” instead

  3. Agenda • Overview of WIA Components • WIA Item Trees • Run-time behavior of WIA Drivers • Troubleshooting and Debugging • Hints and Tips • What can you do next?

  4. WIA Component Architecture Process boundary TWAIN Application WIA Application Key COM Proxy Microsoft Component TWAIN Data Source Default UI Optional vendor UI IHV Component ISV Component STI Interface WIA / STI service USD USD User Mode Kernel Mode USB Driver 1394 Driver SCSI Driver Serial Driver

  5. WIA Item TreesGeneral • Device (and any data) represented by “Items” • Two kinds of items • Driver items and Application items • Driver creates tree of Driver items • WIA Service will build copy of tree for applications (using Application items)

  6. Root IWiaItem Application 1 First Child IWiaItem Second Child IWiaItem Root IWiaItem Application 2 First Child IWiaItem Second Child IWiaItem WIA Item TreesGeneral WIA Driver Root IWiaDrvItem First Child IWiaDrvItem Second Child IWiaDrvItem

  7. WIA Item TreesGeneral • Each Application item has its own property stream • Service will call driver to set initial property values • Driver notified when Application reads/writes properties

  8. WIA Item TreesItem Types • Informs applications how to treat an item • For example, WiaItemTypeAudio • Item types are not exclusive • For example, (WiaItemTypeFile | WiaItemTypeImage) • Driver specifies item type when it creates the item

  9. WIA Item TreesAnnotations • Some data may be associated with other data • Example: Audio recording for a picture • WIA represents annotations with child-items • Items with annotations have special item type flags

  10. Picture 1 Picture 1 (WiaItemTypeFile | WiaItemTypeImage) (WiaItemTypeFile | WiaItemTypeImage | WiaItemTypeHasAttachments) Audio Annotation for Picture 1 Audio Annotation for Picture 1 (WiaItemTypeFile | WiaItemTypeAudio) (WiaItemTypeFile | WiaItemTypeAudio) Picture 2 Picture 2 (WiaItemTypeFile | WiaItemTypeImage) (WiaItemTypeFile | WiaItemTypeImage) WIA Item TreesAnnotations: Example Data on Device WIA Item tree Representation

  11. WIA Item TreesInteractions with Driver • Image data exposed through items • Characteristics exposed through properties, for example • Cameras • Picture width / height, Time picture was taken, and so on • Scanners • Set resolution, Set data type, and so on

  12. Read Property X Current value for X drvReadItemProperties If needed, return new value for X Key Microsoft Component IHV Component ISV Component WIA Item TreesInteractions with Driver Application WIA updates property storage WIA Driver Reading Property Example

  13. WIA Item TreesInteractions with Driver: Example • Walk through sample code

  14. Return appropriateerror code Write Property X 1. drvValidateItemProperties 5. Driver returns error 4. Helper returns error 3. Driver calls generic property validation helper Key Microsoft Component IHV Component ISV Component WIA Item TreesInteractions with Driver Application WIA performs rollback by restoring property stream WIA 2. Driver updates dependant properties Driver Writing Invalid Property Example

  15. Run-Time BehaviorUpdating the Driver Tree • Drivers may add and/or remove WIA items, for example • Take picture • Delete picture • Need to let applications know • Use WIA events, for example • WIA_EVENT_ITEM_CREATED • WIA_EVENT_ITEM_DELETED • WIA_EVENT_TREE_UPDATED

  16. Run-Time Behavior Updating the Driver Tree: Example • Walk through sample code

  17. Run-Time Behavior drvInitializeWia / drvUnitializeWia • Used to bracket application sessions • Similar to AddRef / Release • Can use to maintain session Reference Count • Multiple drvInitializeWia calls can be made before the equivalent drvUninitializeWia calls (i.e., can more than one active session)

  18. Run-Time Behavior drvInitializeWia / drvUnitializeWia: Example • Walk through sample code

  19. Run-Time Behavior drvNotifyPnPEvent • Called Asynchronously • Plug and Play • WIA_EVENT_DEVICE_CONNECTED • WIA_EVENT_DEVICE_DISCONNECTED • Power Management • WIA_EVENT_POWER_SUSPEND • WIA_EVENT_POWER_RESUME • I/O Cancellation • WIA_EVENT_CANCEL_IO

  20. Run-Time Behavior drvNotifyPnPEvent: Example • Walk through sample code

  21. Troubleshooting • WIA Service Log file • %windir%\wiadebug.log • Turn on Warnings and Errors: • [HKLM\System\CurrentControlSet\Control\ StillImage\Debug\wiaservc.dll] • “DebugFlags = 0x3” • Example snippet: wiasValidateItemProperties, invalid RANGE value for : (propID) Horizontal Start Position, value = 3000 Valid RANGE is: MIN = 0, MAX = 1274, STEP = 1

  22. DebuggingOverview • Why use a debugger? • Driver faults (without debugger - service will catch and simply return “failed”) • Service faults (without debugger – service process is terminated) • When do you start the debugger? • Automatically on startup • Attach at run-time

  23. Debugging

  24. Process boundary TWAIN Application WIA Application Key COM Proxy Microsoft Component Default UI Optional vendor UI TWAIN Data Source IHV Component ISV Component STI Interface WIA / STI service USD USD User Mode Kernel Mode USB Driver 1394 Driver SCSI Driver Serial Driver Hints And Tips • USD does not show U.I.! • Multiple instances of driver when using STI

  25. Hints And Tips • IWiaMiniDrv portion of driver only initialized and/or used when application talks WIA • drvInitializeWia / drvUnitializeWia not used to indicate driver loading or unloading • Use WIA’s pre-defined Event GUIDs for Scan, Fax, and so on

  26. What Can You Do Next • Reference the platform SDK/DDK • For more technical details about WIA driver development • http://www.microsoft.com/hwdev/wia • For information about WHQL testing • http://www.microsoft.com/hwtest • Send e-mail to • winimage@microsoft.com

More Related