]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/isys_stream2mmio_rmgr.c
Merge remote-tracking branch 'asoc/topic/pcm512x' into asoc-next
[mirror_ubuntu-focal-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / runtime / isys / src / isys_stream2mmio_rmgr.c
CommitLineData
a49d2536
AC
1#ifndef ISP2401
2/*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#else
d929fb4e 16/*
a49d2536
AC
17Support for Intel Camera Imaging ISP subsystem.
18Copyright (c) 2010 - 2015, Intel Corporation.
19
20This program is free software; you can redistribute it and/or modify it
21under the terms and conditions of the GNU General Public License,
22version 2, as published by the Free Software Foundation.
23
24This program is distributed in the hope it will be useful, but WITHOUT
25ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
27more details.
28*/
29#endif
30
31#include "system_global.h"
32
33#ifdef USE_INPUT_SYSTEM_VERSION_2401
34
35#include "assert_support.h"
36#include "platform_support.h"
37#include "ia_css_isys.h"
38#include "bitop_support.h"
39#include "isys_stream2mmio_rmgr.h"
40
41static isys_stream2mmio_rsrc_t isys_stream2mmio_rsrc[N_STREAM2MMIO_ID];
42
43void ia_css_isys_stream2mmio_sid_rmgr_init(void)
44{
45 memset(isys_stream2mmio_rsrc, 0, sizeof(isys_stream2mmio_rsrc));
46}
47
48void ia_css_isys_stream2mmio_sid_rmgr_uninit(void)
49{
50 memset(isys_stream2mmio_rsrc, 0, sizeof(isys_stream2mmio_rsrc));
51}
52
53bool ia_css_isys_stream2mmio_sid_rmgr_acquire(
54 stream2mmio_ID_t stream2mmio,
55 stream2mmio_sid_ID_t *sid)
56{
57 bool retval = false;
58 stream2mmio_sid_ID_t max_sid;
59 isys_stream2mmio_rsrc_t *cur_rsrc = NULL;
60 stream2mmio_sid_ID_t i;
61
62 assert(stream2mmio < N_STREAM2MMIO_ID);
63 assert(sid != NULL);
64
65 if ((stream2mmio < N_STREAM2MMIO_ID) && (sid != NULL)) {
66 max_sid = N_STREAM2MMIO_SID_PROCS[stream2mmio];
67 cur_rsrc = &isys_stream2mmio_rsrc[stream2mmio];
68
69 if (cur_rsrc->num_active < max_sid) {
70 for (i = STREAM2MMIO_SID0_ID; i < max_sid; i++) {
71 if (bitop_getbit(cur_rsrc->active_table, i) == 0) {
72 bitop_setbit(cur_rsrc->active_table, i);
73 *sid = i;
74 cur_rsrc->num_active++;
75 retval = true;
76 break;
77 }
78 }
79 }
80 }
81 return retval;
82}
83
84void ia_css_isys_stream2mmio_sid_rmgr_release(
85 stream2mmio_ID_t stream2mmio,
86 stream2mmio_sid_ID_t *sid)
87{
88 stream2mmio_sid_ID_t max_sid;
89 isys_stream2mmio_rsrc_t *cur_rsrc = NULL;
90
91 assert(stream2mmio < N_STREAM2MMIO_ID);
92 assert(sid != NULL);
93
94 if ((stream2mmio < N_STREAM2MMIO_ID) && (sid != NULL)) {
95 max_sid = N_STREAM2MMIO_SID_PROCS[stream2mmio];
96 cur_rsrc = &isys_stream2mmio_rsrc[stream2mmio];
97 if ((*sid < max_sid) && (cur_rsrc->num_active > 0)) {
98 if (bitop_getbit(cur_rsrc->active_table, *sid) == 1) {
99 bitop_clearbit(cur_rsrc->active_table, *sid);
100 cur_rsrc->num_active--;
101 }
102 }
103 }
104}
105#endif