ASoC: cs42l73: Remove trailing semicolon
[sfrench/cifs-2.6.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / runtime / event / src / event.c
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
16 /**
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
19
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.
23
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
27 more details.
28 */
29 #endif
30
31 #include "sh_css_sp.h"
32
33 #include "dma.h"        /* N_DMA_CHANNEL_ID */
34
35 #include <type_support.h>
36 #include "ia_css_binary.h"
37 #include "sh_css_hrt.h"
38 #include "sh_css_defs.h"
39 #include "sh_css_internal.h"
40 #include "ia_css_debug.h"
41 #include "ia_css_debug_internal.h"
42 #include "sh_css_legacy.h"
43
44 #include "gdc_device.h"                         /* HRT_GDC_N */
45
46 /*#include "sp.h"*/     /* host2sp_enqueue_frame_data() */
47
48 #include "memory_access.h"
49
50 #include "assert_support.h"
51 #include "platform_support.h"   /* hrt_sleep() */
52
53 #include "ia_css_queue.h"       /* host_sp_enqueue_XXX */
54 #include "ia_css_event.h"       /* ia_css_event_encode */
55 /**
56  * @brief Encode the information into the software-event.
57  * Refer to "sw_event_public.h" for details.
58  */
59 bool ia_css_event_encode(
60         uint8_t *in,
61         uint8_t nr,
62         uint32_t        *out)
63 {
64         bool ret;
65         uint32_t nr_of_bits;
66         uint32_t i;
67         assert(in != NULL);
68         assert(out != NULL);
69         OP___assert(nr > 0 && nr <= MAX_NR_OF_PAYLOADS_PER_SW_EVENT);
70
71         /* initialize the output */
72         *out = 0;
73
74         /* get the number of bits per information */
75         nr_of_bits = sizeof(uint32_t) * 8 / nr;
76
77         /* compress the all inputs into a signle output */
78         for (i = 0; i < nr; i++) {
79                 *out <<= nr_of_bits;
80                 *out |= in[i];
81         }
82
83         /* get the return value */
84         ret = (nr > 0 && nr <= MAX_NR_OF_PAYLOADS_PER_SW_EVENT);
85
86         return ret;
87 }
88
89 void ia_css_event_decode(
90         uint32_t event,
91         uint8_t *payload)
92 {
93         assert(payload[1] == 0);
94         assert(payload[2] == 0);
95         assert(payload[3] == 0);
96
97         ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_event_decode() enter:\n");
98
99         /* First decode according to the common case
100          * In case of a PORT_EOF event we overwrite with
101          * the specific values
102          * This is somewhat ugly but probably somewhat efficient
103          * (and it avoids some code duplication)
104          */
105         payload[0] = event & 0xff;  /*event_code */
106         payload[1] = (event >> 8) & 0xff;
107         payload[2] = (event >> 16) & 0xff;
108         payload[3] = 0;
109
110         switch (payload[0]) {
111         case SH_CSS_SP_EVENT_PORT_EOF:
112                 payload[2] = 0;
113                 payload[3] = (event >> 24) & 0xff;
114                 break;
115
116         case SH_CSS_SP_EVENT_ACC_STAGE_COMPLETE:
117         case SH_CSS_SP_EVENT_TIMER:
118         case SH_CSS_SP_EVENT_FRAME_TAGGED:
119         case SH_CSS_SP_EVENT_FW_WARNING:
120         case SH_CSS_SP_EVENT_FW_ASSERT:
121                 payload[3] = (event >> 24) & 0xff;
122                 break;
123         default:
124                 break;
125         }
126 }