๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Mastering Linux Device Driver Development: Write custom device drivers to support computer peripherals in Linux operating systems

โœ Scribed by John Madieu


Publisher
Packt Publishing Ltd
Year
2021
Tongue
English
Leaves
647
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Synopsis


Master the art of developing customized device drivers for your embedded Linux systems

Key Features

  • Stay up to date with the Linux PCI, ASoC, and V4L2 subsystems and write device drivers for them
  • Get to grips with the Linux kernel power management infrastructure
  • Adopt a practical approach to customizing your Linux environment using best practices

Book Description

Linux is one of the fastest-growing operating systems around the world, and in the last few years, the Linux kernel has evolved significantly to support a wide variety of embedded devices with its improved subsystems and a range of new features. With this book, you'll find out how you can enhance your skills to write custom device drivers for your Linux operating system.

Mastering Linux Device Driver Development provides complete coverage of kernel topics, including video and audio frameworks, that usually go unaddressed. You'll work with some of the most complex and impactful Linux kernel frameworks, such as PCI, ALSA for SoC, and Video4Linux2, and discover expert tips and best practices along the way. In addition to this, you'll understand how to make the most of frameworks such as NVMEM and Watchdog. Once you've got to grips with Linux kernel helpers, you'll advance to working with special device types such as Multi-Function Devices (MFD) followed by video and audio device drivers.

By the end of this book, you'll be able to write feature-rich device drivers and integrate them with some of the most complex Linux kernel frameworks, including V4L2 and ALSA for SoC.

What you will learn

  • Explore and adopt Linux kernel helpers for locking, work deferral, and interrupt management
  • Understand the Regmap subsystem to manage memory accesses and work with the IRQ subsystem
  • Get to grips with the PCI subsystem and write reliable drivers for PCI devices
  • Write full multimedia device drivers using ALSA SoC and the V4L2 framework
  • Build power-aware device drivers using the kernel power management framework
  • Find out how to get the most out of miscellaneous kernel subsystems such as NVMEM and Watchdog

Who this book is for

This book is for embedded developers, Linux system engineers, and system programmers who want to explore Linux kernel frameworks and subsystems. C programming skills and a basic understanding of driver development are necessary to get started with this book.

โœฆ Table of Contents


Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Section 1:Kernel Core Frameworks for Embedded Device Driver Development
Chapter 01: Linux Kernel Concepts for Embedded Developers
Technical requirements
The kernel locking API and shared objects
Spinlocks
Mutexes
The try-lock method
Waiting, sensing, and blocking in the Linux kernel
Work deferring mechanisms
SoftIRQs
Tasklets
Workqueues
Workqueues โ€“ a new generation
Linux kernel interrupt management
Designing an interrupt handler
Summary
Chapter 02: Leveraging the Regmap API and Simplifying the Code
Technical requirements
Introduction to regmap and its data structures โ€“ I2C, SPI, and MMIO
Accessing device registers
Quick recap on Linux kernel IRQ management
Regmap IRQ API and data structures
Summary
Chapter 03: Delving into the MFD Subsystem and Syscon API
Technical requirements
Introducing the MFD subsystem and Syscon APIs
Device tree binding for MFD devices
Understanding Syscon and simple-mfd
Introducing simple-mfd
Summary
Chapter 04: Storming the Common Clock Framework
Technical requirements
CCF data structures and interfaces
Understanding struct clk_hw and its dependencies
Registering/unregistering the clock provider
Exposing clocks to others (in detail)
Writing a clock provider driver
Providing clock ops
Putting it all together โ€“ global overview
Grabbing and releasing clocks
Preparing/unpreparing clocks
Rate functions
Parent functions
Putting it all together
Section 2: Multimedia and Power Saving in Embedded Linux Systems
Chapter 05: ALSA SoC Framework โ€“ Leveraging Codec and Platform Class Drivers
Technical requirements
Introduction to ASoC
ASoC Digital Audio Interface
ASoC sub-elements
Writing codec class drivers
Codec DAI and PCM (AKA DSP) configurations
The concept of controls
The concept of DAPM
Writing the platform class driver
The CPU DAI driver
The platform DMA driver AKA PCM DMA driver
Summary
Chapter 06: ALSA SoC Framework โ€“ Delving into the Machine Class Drivers
Technical requirements
Introduction to machine class drivers
The DAI link
Machine routing consideration
Codec pins
Board connectors
Machine routing
Clocking and formatting considerations
Sound card registration
Leveraging the simple-card machine driver
Codec-less sound cards
Summary
Chapter 07: Demystifying V4L2 and Video Capture Device Drivers
Technical requirements
Framework architecture and the main data structures
Initializing and registering a V4L2 device
Introducing video device drivers โ€“ the bridge driver
Initializing and registering the video device
Video device file operations
V4L2 ioctl handling
The videobuf2 interface and APIs
The concept of sub-devices
Sub-device initialization
Sub-device operations
Traditional sub-device (un)registration
V4L2 controls infrastructure
A word about control inheritance
Summary
Chapter 08: Integrating with V4L2 Async and Media Controller Frameworks
Technical requirements
The V4L2 async interface and the concept of graph binding
Graph binding
The V4L2 async and graph-oriented API
V4L2 async
The Linux media controller framework
The media controller abstraction model
Integrating media controller support in the driver
Media controller from user space
Summary
Chapter 09: Leveraging the V4L2 API from the User Space
Technical requirements
Introduction to V4L2 from user space
The V4L2 user space API
Video device opening and property management
Querying the device capabilities
Buffer management
Image (buffer) format
Requesting buffers
Enqueueing the buffer and enabling streaming
Dequeuing buffers
V4L2 user space tools
Using v4l2-ctl
Debugging V4L2 in user space
Summary
Chapter 10: Linux Kernel Power Management
Technical requirements
The concept of power management on Linux-based systems
Runtime power management
System power management sleep states
Adding power management capabilities to device drivers
Implementing runtime PM capability
System suspend and resume sequences
Implementing system sleep capability
Being a source of system wakeup
Wakeup source and sysfs (or debugfs)
The IRQF_NO_SUSPEND flag
Summary
Section 3: Staying Up to Date with Other Linux Kernel Subsystems
Chapter 11: Writing PCI Device Drivers
Technical requirements
Introduction to PCI buses and interfaces
Terminology
PCI bus enumeration, device configuration, and addressing
PCI address spaces
Interrupt distribution
The Linux kernel PCI subsystem and data structures
PCI data structures
Overview of the PCI driver structure
PCI and Direct Memory Access (DMA)
PCI coherent (aka consistent) mapping
Streaming DMA mapping
Summary
Chapter 12: Leveraging the NVMEM Framework
Technical requirements
Introducing NVMEM data structures and APIs
Writing the NVMEM provider driver
NVMEM device (un)registration
Implementing NVMEM read/write callbacks
Device tree bindings for NVMEM providers
NVMEM consumer driver APIs
NVMEM in user space
Summary
Chapter 13: Watchdog Device Drivers
Technical requirements
Watchdog data structures and APIs
Registering/unregistering a watchdog device
Handling pretimeouts and governors
GPIO-based watchdogs
The watchdog user space interface
Starting and stopping the watchdog
Getting watchdog capabilities and identity
Setting and getting the timeout and pretimeout
Getting the (boot/reboot) status
The watchdog sysfs interface
Summary
Chapter 14: Linux Kernel Debugging Tips and Best Practices
Technical requirements
Understanding the Linux kernel release process
Linux kernel development tips
Message printing
Linux kernel tracing and performance analysis
Using Ftrace to instrument the code
Linux kernel debugging tips
Oops and panic analysis
Using objdump to identify the faulty code line in the kernel module
Summary
Other Books You May Enjoy
Index


๐Ÿ“œ SIMILAR VOLUMES


Mastering Linux Device Driver Developmen
โœ John Madieu ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› Packt Publishing Ltd ๐ŸŒ English

<p><b>Master the art of developing customized device drivers for your embedded Linux systems</b></p>Key Features<ul><li>Stay up to date with the Linux PCI, ASoC, and V4L2 subsystems and write device drivers for them</li><li>Get to grips with the Linux kernel power management infrastructure</li><li>A

Linux Device Drivers Development: Develo
โœ John Madieu ๐Ÿ“‚ Library ๐Ÿ“… 2017 ๐Ÿ› Packt Publishing ๐ŸŒ English

Key Features โ€ข Learn to develop customized Linux device drivers โ€ข Learn the core concepts of device drivers such as memory management, kernel caching, advanced IRQ management, and so on. โ€ข Practical experience on the embedded side of Linux Book Description Linux kernel is a complex, portable,

Linux Device Driver Development Cookbook
โœ Rodolfo Giometti ๐Ÿ“‚ Library ๐Ÿ“… 2019 ๐Ÿ› Packt Publishing ๐ŸŒ English

Over 30 recipes to develop custom drivers for your embedded Linux applications. Key Features โ€ข Use Kernel facilities to develop powerful drivers โ€ข Via a practical approach, learn core concepts of developing device drivers โ€ข Program a custom character device to get access to kernel internals Linu