summaryrefslogtreecommitdiff
path: root/cras/src/server/config/cras_device_blocklist.h
blob: d0f750bd0e87a9b66d8e8ba8b6c7b9e888a94597 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/*
 * Keeps a list of playback devices that should be ignored for a card.  This is
 * useful for devices that present non-functional alsa devices.  For instance
 * some mics show a phantom playback device.
 */
#ifndef CRAS_DEVICE_BLOCKLIST_H_
#define CRAS_DEVICE_BLOCKLIST_H_

#include <stdint.h>

#include "cras_types.h"

struct cras_device_blocklist;

/* Creates a blocklist of devices that should never be added to the system.
 * Args:
 *    config_path - Path containing the config files.
 * Returns:
 *    A pointer to the created blocklist on success, NULL on failure.
 */
struct cras_device_blocklist *
cras_device_blocklist_create(const char *config_path);

/* Destroys a blocklist returned by cras_device_blocklist_create().
 * Args:
 *    blocklist - Blocklist returned by cras_device_blocklist_create()
 */
void cras_device_blocklist_destroy(struct cras_device_blocklist *blocklist);

/* Checks if a playback device on a USB card is blocklisted.
 * Args:
 *    blocklist - Blocklist returned by cras_device_blocklist_create()
 *    vendor_id - USB vendor ID.
 *    product_id - USB product ID.
 *    device_index - Index of the alsa device in the card.
 * Returns:
 *  1 if the device is blocklisted, 0 otherwise.
 */
int cras_device_blocklist_check(struct cras_device_blocklist *blocklist,
				unsigned vendor_id, unsigned product_id,
				unsigned desc_checksum, unsigned device_index);

#endif /* CRAS_CARD_DEVICE_BLOCKLIST_H_ */