3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
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.
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
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31 #include "system_global.h"
33 #ifdef USE_INPUT_SYSTEM_VERSION_2401
35 #include "assert_support.h"
36 #include "platform_support.h"
37 #include "ia_css_isys.h"
38 #include "bitop_support.h"
39 #include "isys_dma_rmgr.h"
41 static isys_dma_rsrc_t isys_dma_rsrc
[N_ISYS2401_DMA_ID
];
43 void ia_css_isys_dma_channel_rmgr_init(void)
45 memset(&isys_dma_rsrc
, 0, sizeof(isys_dma_rsrc_t
));
48 void ia_css_isys_dma_channel_rmgr_uninit(void)
50 memset(&isys_dma_rsrc
, 0, sizeof(isys_dma_rsrc_t
));
53 bool ia_css_isys_dma_channel_rmgr_acquire(
54 isys2401_dma_ID_t dma_id
,
55 isys2401_dma_channel
*channel
)
58 isys2401_dma_channel i
;
59 isys2401_dma_channel max_dma_channel
;
60 isys_dma_rsrc_t
*cur_rsrc
= NULL
;
62 assert(dma_id
< N_ISYS2401_DMA_ID
);
63 assert(channel
!= NULL
);
65 max_dma_channel
= N_ISYS2401_DMA_CHANNEL_PROCS
[dma_id
];
66 cur_rsrc
= &isys_dma_rsrc
[dma_id
];
68 if (cur_rsrc
->num_active
< max_dma_channel
) {
69 for (i
= ISYS2401_DMA_CHANNEL_0
; i
< N_ISYS2401_DMA_CHANNEL
; i
++) {
70 if (bitop_getbit(cur_rsrc
->active_table
, i
) == 0) {
71 bitop_setbit(cur_rsrc
->active_table
, i
);
73 cur_rsrc
->num_active
++;
83 void ia_css_isys_dma_channel_rmgr_release(
84 isys2401_dma_ID_t dma_id
,
85 isys2401_dma_channel
*channel
)
87 isys2401_dma_channel max_dma_channel
;
88 isys_dma_rsrc_t
*cur_rsrc
= NULL
;
90 assert(dma_id
< N_ISYS2401_DMA_ID
);
91 assert(channel
!= NULL
);
93 max_dma_channel
= N_ISYS2401_DMA_CHANNEL_PROCS
[dma_id
];
94 cur_rsrc
= &isys_dma_rsrc
[dma_id
];
96 if ((*channel
< max_dma_channel
) && (cur_rsrc
->num_active
> 0)) {
97 if (bitop_getbit(cur_rsrc
->active_table
, *channel
) == 1) {
98 bitop_clearbit(cur_rsrc
->active_table
, *channel
);
99 cur_rsrc
->num_active
--;