linux視頻媒體(kernel層分析)主要包括三個文件:
(/drivers/media/media-device.c , /drivers/media/media-devnode.c , /drivers/media/media-entity.c)
一.主要分析/drivers/media/media-device.c文件,此文件中主要的結構是:
/*dev->driver_data points to this struct*/
struct media_device { //媒體設備結構體 struct device *dev; //Parent device struct media_devnode devnode; //媒體設備節點 char model[32];//設備型號名稱 char driver_name[32]; //驅動的名稱,如果沒有設置,就返回dev->driver->name char serial[40];//設備序列號 char bus_info[32];//設備位置標識符 u32 hw_revision; u32 driver_version; //驅動版本 u32 topology_version; //拓撲版本 u32 id;//注冊的圖形對象上使用的唯一ID struct ida entity_internal_idx; int entity_internal_idx_max; struct list_head entities; //List of registered entities struct list_head interfaces; //List of registered interfaces struct list_head pads; //List of registered pads struct list_head links; //List of registered links
/*entity注冊成功的回調通知鏈表*/ struct list_head entity_notify; //notify callback list invoked when a new entity is registered spinlock_t lock; //Protects the graph objects creation/removal struct mutex graph_mutex; //Serializes graph operations. struct media_entity_graph pm_count_walk; //Graph walk for power state walk. void *source_priv;//Driver Private data for enable/disable source handlers int (*enable_source)(struct media_entity *entity, struct media_pipeline *pipe); void (*disable_source)(struct media_entity *entity);
/**
* Supported link_notify @notification values.
#define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0
#define MEDIA_DEV_NOTIFY_POST_LINK_CH 1
*/
int (*link_notify)(struct media_link *link, u32 flags, unsigned int notification);//Link state change notification callback
};
/*此結構體對應於struct media_device結構體中的 struct list_head entity_notify鏈表*/
struct media_entity_notify { struct list_head list; void *notify_data; // Input data to invoke the callback void (*notify)(struct media_entity *entity, void *notify_data); //Callback function pointer };
主要API:
void media_device_init(struct media_device *mdev);
void media_device_cleanup(struct media_device *mdev);
media_device_register(mdev); // __media_device_register(struct media_device *mdev, struct module *owner);
void media_device_unregister(struct media_device *mdev);