• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010 - 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 
16 #include "system_global.h"
17 
18 #ifdef ISP2401
19 
20 #include "assert_support.h"
21 #include "platform_support.h"
22 #include "ia_css_isys.h"
23 #include "bitop_support.h"
24 #include "isys_stream2mmio_rmgr.h"
25 
26 static isys_stream2mmio_rsrc_t	isys_stream2mmio_rsrc[N_STREAM2MMIO_ID];
27 
ia_css_isys_stream2mmio_sid_rmgr_init(void)28 void ia_css_isys_stream2mmio_sid_rmgr_init(void)
29 {
30 	memset(isys_stream2mmio_rsrc, 0, sizeof(isys_stream2mmio_rsrc));
31 }
32 
ia_css_isys_stream2mmio_sid_rmgr_uninit(void)33 void ia_css_isys_stream2mmio_sid_rmgr_uninit(void)
34 {
35 	memset(isys_stream2mmio_rsrc, 0, sizeof(isys_stream2mmio_rsrc));
36 }
37 
ia_css_isys_stream2mmio_sid_rmgr_acquire(stream2mmio_ID_t stream2mmio,stream2mmio_sid_ID_t * sid)38 bool ia_css_isys_stream2mmio_sid_rmgr_acquire(
39     stream2mmio_ID_t	stream2mmio,
40     stream2mmio_sid_ID_t	*sid)
41 {
42 	bool retval = false;
43 	stream2mmio_sid_ID_t max_sid;
44 	isys_stream2mmio_rsrc_t *cur_rsrc = NULL;
45 	stream2mmio_sid_ID_t	i;
46 
47 	assert(stream2mmio < N_STREAM2MMIO_ID);
48 	assert(sid);
49 
50 	if ((stream2mmio < N_STREAM2MMIO_ID) && (sid)) {
51 		max_sid = N_STREAM2MMIO_SID_PROCS[stream2mmio];
52 		cur_rsrc = &isys_stream2mmio_rsrc[stream2mmio];
53 
54 		if (cur_rsrc->num_active < max_sid) {
55 			for (i = STREAM2MMIO_SID0_ID; i < max_sid; i++) {
56 				if (bitop_getbit(cur_rsrc->active_table, i) == 0) {
57 					bitop_setbit(cur_rsrc->active_table, i);
58 					*sid = i;
59 					cur_rsrc->num_active++;
60 					retval = true;
61 					break;
62 				}
63 			}
64 		}
65 	}
66 	return retval;
67 }
68 
ia_css_isys_stream2mmio_sid_rmgr_release(stream2mmio_ID_t stream2mmio,stream2mmio_sid_ID_t * sid)69 void ia_css_isys_stream2mmio_sid_rmgr_release(
70     stream2mmio_ID_t	stream2mmio,
71     stream2mmio_sid_ID_t	*sid)
72 {
73 	stream2mmio_sid_ID_t max_sid;
74 	isys_stream2mmio_rsrc_t *cur_rsrc = NULL;
75 
76 	assert(stream2mmio < N_STREAM2MMIO_ID);
77 	assert(sid);
78 
79 	if ((stream2mmio < N_STREAM2MMIO_ID) && (sid)) {
80 		max_sid = N_STREAM2MMIO_SID_PROCS[stream2mmio];
81 		cur_rsrc = &isys_stream2mmio_rsrc[stream2mmio];
82 		if ((*sid < max_sid) && (cur_rsrc->num_active > 0)) {
83 			if (bitop_getbit(cur_rsrc->active_table, *sid) == 1) {
84 				bitop_clearbit(cur_rsrc->active_table, *sid);
85 				cur_rsrc->num_active--;
86 			}
87 		}
88 	}
89 }
90 #endif
91