xref: /aosp_15_r20/external/parameter-framework/upstream/doc/requirements/requirements.md (revision c33452fb792a5495ec310a9626f2638b053af5dd)
1*c33452fbSAndroid Build Coastguard Worker% Parameter Framework \
2*c33452fbSAndroid Build Coastguard WorkerHigh level requirements
3*c33452fbSAndroid Build Coastguard Worker
4*c33452fbSAndroid Build Coastguard Worker<!--
5*c33452fbSAndroid Build Coastguard WorkerCopyright (c) 2015, Intel Corporation
6*c33452fbSAndroid Build Coastguard WorkerAll rights reserved.
7*c33452fbSAndroid Build Coastguard Worker
8*c33452fbSAndroid Build Coastguard WorkerRedistribution and use in source and binary forms, with or without modification,
9*c33452fbSAndroid Build Coastguard Workerare permitted provided that the following conditions are met:
10*c33452fbSAndroid Build Coastguard Worker
11*c33452fbSAndroid Build Coastguard Worker1. Redistributions of source code must retain the above copyright notice, this
12*c33452fbSAndroid Build Coastguard Workerlist of conditions and the following disclaimer.
13*c33452fbSAndroid Build Coastguard Worker
14*c33452fbSAndroid Build Coastguard Worker2. Redistributions in binary form must reproduce the above copyright notice,
15*c33452fbSAndroid Build Coastguard Workerthis list of conditions and the following disclaimer in the documentation and/or
16*c33452fbSAndroid Build Coastguard Workerother materials provided with the distribution.
17*c33452fbSAndroid Build Coastguard Worker
18*c33452fbSAndroid Build Coastguard Worker3. Neither the name of the copyright holder nor the names of its contributors
19*c33452fbSAndroid Build Coastguard Workermay be used to endorse or promote products derived from this software without
20*c33452fbSAndroid Build Coastguard Workerspecific prior written permission.
21*c33452fbSAndroid Build Coastguard Worker
22*c33452fbSAndroid Build Coastguard WorkerTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23*c33452fbSAndroid Build Coastguard WorkerANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24*c33452fbSAndroid Build Coastguard WorkerWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25*c33452fbSAndroid Build Coastguard WorkerDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26*c33452fbSAndroid Build Coastguard WorkerANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27*c33452fbSAndroid Build Coastguard Worker(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28*c33452fbSAndroid Build Coastguard WorkerLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29*c33452fbSAndroid Build Coastguard WorkerANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30*c33452fbSAndroid Build Coastguard Worker(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31*c33452fbSAndroid Build Coastguard WorkerSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*c33452fbSAndroid Build Coastguard Worker-->
33*c33452fbSAndroid Build Coastguard Worker
34*c33452fbSAndroid Build Coastguard Worker<article class="markdown-body">
35*c33452fbSAndroid Build Coastguard Worker
36*c33452fbSAndroid Build Coastguard Worker<note>Some requirements are only motivated by the fact that the reference
37*c33452fbSAndroid Build Coastguard Workerimplementation implements them. Search for "reference implementation".</note>
38*c33452fbSAndroid Build Coastguard Worker
39*c33452fbSAndroid Build Coastguard Worker# Introduction
40*c33452fbSAndroid Build Coastguard Worker
41*c33452fbSAndroid Build Coastguard WorkerThe Parameter Framework is abreviated as PF in the rest of the document.
42*c33452fbSAndroid Build Coastguard Worker
43*c33452fbSAndroid Build Coastguard Worker## Philosophy
44*c33452fbSAndroid Build Coastguard Worker
45*c33452fbSAndroid Build Coastguard WorkerThe Parameter Framework aims to be a hardware control abstraction layer.
46*c33452fbSAndroid Build Coastguard WorkerSpecificaly the PF contains 3 stacked abstraction layers:
47*c33452fbSAndroid Build Coastguard Worker
48*c33452fbSAndroid Build Coastguard Worker 1) hardware api abstraction
49*c33452fbSAndroid Build Coastguard Worker 2) hardware parameter abstraction
50*c33452fbSAndroid Build Coastguard Worker 3) high level hardware independent abstraction
51*c33452fbSAndroid Build Coastguard Worker
52*c33452fbSAndroid Build Coastguard WorkerThe fundamental constraint on the underlined hardware is to be representable
53*c33452fbSAndroid Build Coastguard Workerby independent parameters. Ie: When changing one parameter it must not change
54*c33452fbSAndroid Build Coastguard Workeran other.
55*c33452fbSAndroid Build Coastguard Worker
56*c33452fbSAndroid Build Coastguard Worker### Hardware api abstraction
57*c33452fbSAndroid Build Coastguard WorkerThe goal of this layer is to abstract the apis of the underline hardwares.
58*c33452fbSAndroid Build Coastguard WorkerEach abstracted hardware usualy have different apis, this layer responsibility
59*c33452fbSAndroid Build Coastguard Workeris to set and get parameters using the underlined native api.
60*c33452fbSAndroid Build Coastguard Worker
61*c33452fbSAndroid Build Coastguard WorkerSee the [syncer] chapter.
62*c33452fbSAndroid Build Coastguard Worker<!--Fixme why are pandoc auto references not working ? -->
63*c33452fbSAndroid Build Coastguard Worker
64*c33452fbSAndroid Build Coastguard Worker### Hardware parameter abstraction
65*c33452fbSAndroid Build Coastguard WorkerThe goal if this layer is to name and organize and describing
66*c33452fbSAndroid Build Coastguard Workerthe hardware parameter properties (domain of validity, size, human representation...).
67*c33452fbSAndroid Build Coastguard Worker
68*c33452fbSAndroid Build Coastguard WorkerSee the "Parameters" chapter.
69*c33452fbSAndroid Build Coastguard Worker
70*c33452fbSAndroid Build Coastguard Worker### High level hardware independent abstraction
71*c33452fbSAndroid Build Coastguard WorkerThe goal of this layer is to abstract the hardware parameters behind abstract parameters
72*c33452fbSAndroid Build Coastguard Worker(called criterion in the reference implementation).
73*c33452fbSAndroid Build Coastguard Worker
74*c33452fbSAndroid Build Coastguard WorkerThis is done by linking those abstract parameters and the hardware parameters with
75*c33452fbSAndroid Build Coastguard Workerarbitrary rules.
76*c33452fbSAndroid Build Coastguard Worker
77*c33452fbSAndroid Build Coastguard WorkerSee the "Rule based dynamic abstraction".
78*c33452fbSAndroid Build Coastguard Worker
79*c33452fbSAndroid Build Coastguard Worker## Requirements
80*c33452fbSAndroid Build Coastguard Worker
81*c33452fbSAndroid Build Coastguard Worker### Reusability
82*c33452fbSAndroid Build Coastguard WorkerThe PF **SHOULD** be reusable between components.
83*c33452fbSAndroid Build Coastguard Worker<why>To be reused in different components.</why>
84*c33452fbSAndroid Build Coastguard Worker
85*c33452fbSAndroid Build Coastguard Worker### Instances independence
86*c33452fbSAndroid Build Coastguard WorkerPF instances **MUST NOT** mutate each others.
87*c33452fbSAndroid Build Coastguard Worker<note>This may be implemented by not sharing any mutable data between PF instances.</note>
88*c33452fbSAndroid Build Coastguard Worker<why>Different PF instances are expected to be completely independent thus accessing one should not impact any others.</why>
89*c33452fbSAndroid Build Coastguard Worker
90*c33452fbSAndroid Build Coastguard Worker# Parameters
91*c33452fbSAndroid Build Coastguard Worker
92*c33452fbSAndroid Build Coastguard Worker<note>TODO: add a paragraph/requirement about parameter independences.
93*c33452fbSAndroid Build Coastguard WorkerIe parameter set order should not impact the final state.
94*c33452fbSAndroid Build Coastguard WorkerNeed to find justification for this. Maybe it is only a convention?
95*c33452fbSAndroid Build Coastguard WorkerMaybe it is a consequences of the domains ?</note>
96*c33452fbSAndroid Build Coastguard Worker
97*c33452fbSAndroid Build Coastguard Worker
98*c33452fbSAndroid Build Coastguard Worker## Definitions
99*c33452fbSAndroid Build Coastguard Worker
100*c33452fbSAndroid Build Coastguard Worker<dl>
101*c33452fbSAndroid Build Coastguard Worker<dt>Parameter</dt>
102*c33452fbSAndroid Build Coastguard Worker<dd>TODO</dd>
103*c33452fbSAndroid Build Coastguard Worker<dt>Hardware</dt>
104*c33452fbSAndroid Build Coastguard Worker<dd>System controlled by the PF. Not necessary material system. This term was
105*c33452fbSAndroid Build Coastguard Workerchosen because:
106*c33452fbSAndroid Build Coastguard Worker
107*c33452fbSAndroid Build Coastguard Worker - historically the PF reference implementation was used to abstract hardware
108*c33452fbSAndroid Build Coastguard Worker - the subsystem term would arguably fit best is already used.
109*c33452fbSAndroid Build Coastguard Worker
110*c33452fbSAndroid Build Coastguard Worker(FIXME: choose "subsystem" instead of "hardware" ?)
111*c33452fbSAndroid Build Coastguard Worker</dd>
112*c33452fbSAndroid Build Coastguard Worker</dl>
113*c33452fbSAndroid Build Coastguard Worker
114*c33452fbSAndroid Build Coastguard Worker## Requirements
115*c33452fbSAndroid Build Coastguard WorkerA PF **MUST** be able to handle parameters.
116*c33452fbSAndroid Build Coastguard Worker<why>because the PF aims to abstract hardware and model it by parameters.</why>
117*c33452fbSAndroid Build Coastguard Worker
118*c33452fbSAndroid Build Coastguard Worker## Value
119*c33452fbSAndroid Build Coastguard Worker
120*c33452fbSAndroid Build Coastguard WorkerA parameter **MUST** have a value.
121*c33452fbSAndroid Build Coastguard Worker<why>because a parameter without value would not abstract any hardware.</why>
122*c33452fbSAndroid Build Coastguard Worker
123*c33452fbSAndroid Build Coastguard Worker### Mutability
124*c33452fbSAndroid Build Coastguard WorkerA PF **MUST** support mutable parameters.
125*c33452fbSAndroid Build Coastguard Worker<why>To control the underlined hardware.</why>
126*c33452fbSAndroid Build Coastguard Worker
127*c33452fbSAndroid Build Coastguard Worker### Set ability
128*c33452fbSAndroid Build Coastguard WorkerThis value **MUST** be settable for a mutable parameter.
129*c33452fbSAndroid Build Coastguard Worker<why>By definition, a mutable parameter that can not be mutated it a immutable parameter.</why>
130*c33452fbSAndroid Build Coastguard Worker
131*c33452fbSAndroid Build Coastguard Worker### Get ability
132*c33452fbSAndroid Build Coastguard WorkerThis value **SHOULD** be gettable for a mutable parameter.
133*c33452fbSAndroid Build Coastguard Worker<why>To dump all parameter value, debug a hardware state,
134*c33452fbSAndroid Build Coastguard Workersave parameters values, display the current hardware state,
135*c33452fbSAndroid Build Coastguard Workerfor coherency with the immutable parameter...</why>
136*c33452fbSAndroid Build Coastguard Worker
137*c33452fbSAndroid Build Coastguard Worker### Data type
138*c33452fbSAndroid Build Coastguard Worker
139*c33452fbSAndroid Build Coastguard Worker#### Definition
140*c33452fbSAndroid Build Coastguard Worker
141*c33452fbSAndroid Build Coastguard Worker<dl>
142*c33452fbSAndroid Build Coastguard Worker<dt>Data type</dt>
143*c33452fbSAndroid Build Coastguard Worker<dd>
144*c33452fbSAndroid Build Coastguard WorkerAll parameters have a data type. A data type designates parameter invariants.
145*c33452fbSAndroid Build Coastguard Worker
146*c33452fbSAndroid Build Coastguard WorkerA data type is the meaning of the data and the way values of that type can be
147*c33452fbSAndroid Build Coastguard Workerstored.
148*c33452fbSAndroid Build Coastguard Worker</dd>
149*c33452fbSAndroid Build Coastguard Worker</dl>
150*c33452fbSAndroid Build Coastguard Worker
151*c33452fbSAndroid Build Coastguard Worker
152*c33452fbSAndroid Build Coastguard Worker#### Philosophy
153*c33452fbSAndroid Build Coastguard Worker
154*c33452fbSAndroid Build Coastguard WorkerA data type defines the value properties:
155*c33452fbSAndroid Build Coastguard Worker
156*c33452fbSAndroid Build Coastguard Worker - memory layout
157*c33452fbSAndroid Build Coastguard Worker - value constrains
158*c33452fbSAndroid Build Coastguard Worker
159*c33452fbSAndroid Build Coastguard WorkerA value type is mostly used to:
160*c33452fbSAndroid Build Coastguard Worker
161*c33452fbSAndroid Build Coastguard Worker - pretty display parameter values (not just a as an array of bits)
162*c33452fbSAndroid Build Coastguard Worker - check for user error when setting it (out of bound, invalid...)
163*c33452fbSAndroid Build Coastguard Worker - offer a type safe API
164*c33452fbSAndroid Build Coastguard Worker
165*c33452fbSAndroid Build Coastguard Worker#### Requirements
166*c33452fbSAndroid Build Coastguard Worker
167*c33452fbSAndroid Build Coastguard Worker##### Supported types
168*c33452fbSAndroid Build Coastguard WorkerA PF **SHOULD** support the following types.
169*c33452fbSAndroid Build Coastguard WorkerIf a type is chosen to be supported, it **MUST** respect all MUST clause,
170*c33452fbSAndroid Build Coastguard Worker**SHOULD** respect all SHOULD clause, **MAY** respect all MAY clause of the type.
171*c33452fbSAndroid Build Coastguard Worker<why>All type are not necessary to use the PF. For example any parameter could
172*c33452fbSAndroid Build Coastguard Workerbe represented as an array of char (string). But this would not permit to
173*c33452fbSAndroid Build Coastguard Workercheck parameter validity (invariants) nor a pretty display of the values.</why>
174*c33452fbSAndroid Build Coastguard Worker
175*c33452fbSAndroid Build Coastguard Worker##### Typed API
176*c33452fbSAndroid Build Coastguard WorkerImplementation **MAY** add another API to access a parameter value.
177*c33452fbSAndroid Build Coastguard Worker<why>For example a C++ implementation may give access to a string as an
178*c33452fbSAndroid Build Coastguard Workerstd::string object.</why>
179*c33452fbSAndroid Build Coastguard Worker
180*c33452fbSAndroid Build Coastguard Worker##### Integers
181*c33452fbSAndroid Build Coastguard Worker
182*c33452fbSAndroid Build Coastguard Worker###### Signed and unsigned support
183*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support signed and unsigned integer parameters
184*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation supports it.</why>
185*c33452fbSAndroid Build Coastguard Worker
186*c33452fbSAndroid Build Coastguard Worker###### Size immutability
187*c33452fbSAndroid Build Coastguard WorkerPF **MUST** support integer with invariant size.
188*c33452fbSAndroid Build Coastguard Worker<why>It is common in C API to expect numbers to have a fixed maximum size.</why>
189*c33452fbSAndroid Build Coastguard Worker
190*c33452fbSAndroid Build Coastguard Worker###### ABI
191*c33452fbSAndroid Build Coastguard WorkerThe API to access it **MUST** respect C integer ABI.
192*c33452fbSAndroid Build Coastguard Worker<why>For easy access from C code.</why>
193*c33452fbSAndroid Build Coastguard Worker
194*c33452fbSAndroid Build Coastguard Worker###### Supported size
195*c33452fbSAndroid Build Coastguard WorkerSupported integer size **SHOULD** be at least 8, 16 and 32 bits.
196*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation supports it.</why>
197*c33452fbSAndroid Build Coastguard Worker
198*c33452fbSAndroid Build Coastguard Worker###### Min max support
199*c33452fbSAndroid Build Coastguard WorkerPF **MAY** support constraining the parameter minimum and maximum value.
200*c33452fbSAndroid Build Coastguard Worker<why>To catch user out of valid range errors when changing the parameter
201*c33452fbSAndroid Build Coastguard Workervalue.</why>
202*c33452fbSAndroid Build Coastguard Worker
203*c33452fbSAndroid Build Coastguard Worker##### String
204*c33452fbSAndroid Build Coastguard Worker###### Support
205*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support array of characters.
206*c33452fbSAndroid Build Coastguard Worker<why>Everything that a computer can store fits in an array of characters. It can
207*c33452fbSAndroid Build Coastguard Workerbe used as a fallback type if no other matches the parameter.</why>
208*c33452fbSAndroid Build Coastguard Worker
209*c33452fbSAndroid Build Coastguard Worker###### String max size
210*c33452fbSAndroid Build Coastguard WorkerThe array maximum size **MAY** be invariant (immutable).
211*c33452fbSAndroid Build Coastguard Worker<unknown>This is what the reference implementation does.</unknown>
212*c33452fbSAndroid Build Coastguard Worker
213*c33452fbSAndroid Build Coastguard Worker###### API
214*c33452fbSAndroid Build Coastguard WorkerThe API to access the string value **SHOULD** support null terminated character
215*c33452fbSAndroid Build Coastguard Workerarray. As it is commonly done in C.
216*c33452fbSAndroid Build Coastguard Worker<why>For easy access from C code.</why>
217*c33452fbSAndroid Build Coastguard Worker
218*c33452fbSAndroid Build Coastguard Worker##### Fix point parameter
219*c33452fbSAndroid Build Coastguard Worker
220*c33452fbSAndroid Build Coastguard Worker###### Support
221*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support fix point parameters. I.e. integers divided by a fixed power
222*c33452fbSAndroid Build Coastguard Workerof two.
223*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
224*c33452fbSAndroid Build Coastguard Worker
225*c33452fbSAndroid Build Coastguard Worker###### API
226*c33452fbSAndroid Build Coastguard WorkerThe API to access the values **SHOULD** respect the Qm.n and UQm.n standards.
227*c33452fbSAndroid Build Coastguard Worker<why>It is the main standard for fix point parameters.</why>
228*c33452fbSAndroid Build Coastguard Worker
229*c33452fbSAndroid Build Coastguard Worker###### Size
230*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support at least `0 <= m + n <= 31` for a Signed Qm.n and
231*c33452fbSAndroid Build Coastguard Worker`0 <= m + n <= 32` for an Unsigned Qm.n (or "UQm.n").
232*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
233*c33452fbSAndroid Build Coastguard Worker<ko>The reference implementation only supports Signed Qn.m</ko>
234*c33452fbSAndroid Build Coastguard Worker
235*c33452fbSAndroid Build Coastguard Worker###### Min and max support
236*c33452fbSAndroid Build Coastguard WorkerPF **MAY** support constraining the parameter minimum and maximum value.
237*c33452fbSAndroid Build Coastguard Worker<why>To catch user out of valid range errors when changing the parameter
238*c33452fbSAndroid Build Coastguard Workervalue.</why>
239*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation does not support it</unknown>
240*c33452fbSAndroid Build Coastguard Worker
241*c33452fbSAndroid Build Coastguard Worker##### Floating point
242*c33452fbSAndroid Build Coastguard Worker###### Support
243*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support floating point parameters .
244*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
245*c33452fbSAndroid Build Coastguard Worker
246*c33452fbSAndroid Build Coastguard Worker###### API
247*c33452fbSAndroid Build Coastguard WorkerThe API to access the values **SHOULD** respect C platform float abi.
248*c33452fbSAndroid Build Coastguard Worker<note>Usually the IEEE 754 standard.</note>
249*c33452fbSAndroid Build Coastguard Worker
250*c33452fbSAndroid Build Coastguard Worker###### Size
251*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support at least 32 and 64 bit size floats.
252*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation supports it.</why>
253*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation only supports 32bits</unknown>
254*c33452fbSAndroid Build Coastguard Worker
255*c33452fbSAndroid Build Coastguard Worker###### Min and max support
256*c33452fbSAndroid Build Coastguard WorkerPF **MAY** support constraining the parameter minimum and maximum value.
257*c33452fbSAndroid Build Coastguard Worker<why>To catch user out of valid range errors when changing the parameter
258*c33452fbSAndroid Build Coastguard Workervalue.</why>
259*c33452fbSAndroid Build Coastguard Worker
260*c33452fbSAndroid Build Coastguard Worker##### Bit field
261*c33452fbSAndroid Build Coastguard Worker
262*c33452fbSAndroid Build Coastguard Worker###### Support
263*c33452fbSAndroid Build Coastguard WorkerPF **SHOULD** support 1 or more bit sized integers.
264*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
265*c33452fbSAndroid Build Coastguard Worker
266*c33452fbSAndroid Build Coastguard Worker###### Single bit access API
267*c33452fbSAndroid Build Coastguard WorkerThe API to access a bit parameter is implementation defined.
268*c33452fbSAndroid Build Coastguard Worker<why>C has no way to point to a single (or more) bits. Thus there is no </why>
269*c33452fbSAndroid Build Coastguard Worker
270*c33452fbSAndroid Build Coastguard Worker###### Bit field access API
271*c33452fbSAndroid Build Coastguard WorkerSuch bit parameters **SHOULD** be grouped in a bit field.
272*c33452fbSAndroid Build Coastguard WorkerA bit field is an ordered set of bit parameter.
273*c33452fbSAndroid Build Coastguard WorkerThe API to access a bit filed **SHOULD** give access to a packed bit
274*c33452fbSAndroid Build Coastguard Workerfield following the C abi.
275*c33452fbSAndroid Build Coastguard Worker<note>This bit field may contain only bit parameter.</note>
276*c33452fbSAndroid Build Coastguard Worker<why>To offer a C compatible api to fit field.</why>
277*c33452fbSAndroid Build Coastguard Worker
278*c33452fbSAndroid Build Coastguard Worker
279*c33452fbSAndroid Build Coastguard Worker### Parameter adaptation
280*c33452fbSAndroid Build Coastguard Worker
281*c33452fbSAndroid Build Coastguard Worker#### Definition
282*c33452fbSAndroid Build Coastguard Worker<dl>
283*c33452fbSAndroid Build Coastguard Worker<dt>Parameter adaptation<dt>
284*c33452fbSAndroid Build Coastguard Worker<dd>
285*c33452fbSAndroid Build Coastguard WorkerA bijective pure function converting a parameter value between the syncer
286*c33452fbSAndroid Build Coastguard Workerand other parameter reader/writer (including the inference engine).
287*c33452fbSAndroid Build Coastguard Worker
288*c33452fbSAndroid Build Coastguard WorkerThe adaptation function maps the syncer and client space. It:
289*c33452fbSAndroid Build Coastguard Worker
290*c33452fbSAndroid Build Coastguard Worker - scales the user value to the hardware value (client => syncer)
291*c33452fbSAndroid Build Coastguard Worker - converts the hardware value to the user's value space. (syncer => client)
292*c33452fbSAndroid Build Coastguard Worker
293*c33452fbSAndroid Build Coastguard Worker<why>For coherency a client getting a previously set parameter should return the setted value,
294*c33452fbSAndroid Build Coastguard Workerthus the transformation must be bijective.
295*c33452fbSAndroid Build Coastguard Worker</why>
296*c33452fbSAndroid Build Coastguard Worker</dd>
297*c33452fbSAndroid Build Coastguard Worker</dl>
298*c33452fbSAndroid Build Coastguard Worker
299*c33452fbSAndroid Build Coastguard Worker#### Philosophy
300*c33452fbSAndroid Build Coastguard Worker
301*c33452fbSAndroid Build Coastguard WorkerParameters exposed by hardware sometimes need to be normalized.
302*c33452fbSAndroid Build Coastguard Worker<note>For example a hardware integer parameter could have a range 64-128 but it might
303*c33452fbSAndroid Build Coastguard Workerbe necessary for upper layer to access in a range 0-100.</note>\
304*c33452fbSAndroid Build Coastguard Worker
305*c33452fbSAndroid Build Coastguard WorkerThis transformation can also permits to change the unit of a parameter.
306*c33452fbSAndroid Build Coastguard Worker<note>For example the hardware could expose a parameter in cm but it might better
307*c33452fbSAndroid Build Coastguard Workerto expose it in mm. </note>\
308*c33452fbSAndroid Build Coastguard Worker
309*c33452fbSAndroid Build Coastguard WorkerParameters types offer a way to abstract underlined implementation.
310*c33452fbSAndroid Build Coastguard Worker<note>For example a Q2,2 (see [fix-point-parameter]) when setting 1
311*c33452fbSAndroid Build Coastguard Workerwill be translated to 0100. </note>\
312*c33452fbSAndroid Build Coastguard Worker
313*c33452fbSAndroid Build Coastguard WorkerWith parameter adaptation, types can be even further parameterised.
314*c33452fbSAndroid Build Coastguard Worker<note>For example, Qn,m Fix point parameter could be emulated with a $*2^n$
315*c33452fbSAndroid Build Coastguard Workeradaptation over an n + m integer. </note>\
316*c33452fbSAndroid Build Coastguard Worker
317*c33452fbSAndroid Build Coastguard WorkerParameter adaptation could be implemented by the syncer.
318*c33452fbSAndroid Build Coastguard WorkerNevertheless syncers are supposed to contain only
319*c33452fbSAndroid Build Coastguard Workerbusiness logic and should not be impacted by upper layer needs.
320*c33452fbSAndroid Build Coastguard Worker
321*c33452fbSAndroid Build Coastguard Worker#### Requirements
322*c33452fbSAndroid Build Coastguard Worker
323*c33452fbSAndroid Build Coastguard Worker##### Support
324*c33452fbSAndroid Build Coastguard WorkerThe following parameter adaptation **SHOULD** be supported
325*c33452fbSAndroid Build Coastguard Worker
326*c33452fbSAndroid Build Coastguard Worker - Affine adaptation: `affAd(value) = slope * value + offset` where slope and
327*c33452fbSAndroid Build Coastguard Worker   offset and user-defined constants
328*c33452fbSAndroid Build Coastguard Worker   <unknown>The reference implementation supports it.</unknown>
329*c33452fbSAndroid Build Coastguard Worker
330*c33452fbSAndroid Build Coastguard Worker - Logarithm adaptation: `logAd(base, value) = ln(value) / ln(base)` where
331*c33452fbSAndroid Build Coastguard Worker   `ln` is the natural logarithm and base is a user-defined constant.
332*c33452fbSAndroid Build Coastguard Worker   <unknown>The reference application supports it.</unknown>
333*c33452fbSAndroid Build Coastguard Worker   <note>The reference implementation also supports passing a floor value to be
334*c33452fbSAndroid Build Coastguard Worker   applied after conversion.</note>
335*c33452fbSAndroid Build Coastguard Worker
336*c33452fbSAndroid Build Coastguard Worker##### Composition
337*c33452fbSAndroid Build Coastguard WorkerA PF **MAY** offer Parameter adaptation composition. I.e. combine multiple parameter
338*c33452fbSAndroid Build Coastguard Workeradaptation
339*c33452fbSAndroid Build Coastguard Worker<note>E.g.: composing the affine and logarithm adaptation to
340*c33452fbSAndroid Build Coastguard Worker`compAd(value) = slope * logAd(base, value) + offset`.</note>
341*c33452fbSAndroid Build Coastguard Worker<why>To avoid combination explosion of parameter adaptations. The idea is to
342*c33452fbSAndroid Build Coastguard Workerbuiltin basic function and let the user compose them to meet its need.</why>
343*c33452fbSAndroid Build Coastguard Worker<ko>The reference application supports in a tricky way: the logarithm
344*c33452fbSAndroid Build Coastguard Workeradaptation is always combined with the affine adaptation</ko>
345*c33452fbSAndroid Build Coastguard Worker
346*c33452fbSAndroid Build Coastguard Worker### Parameter tree
347*c33452fbSAndroid Build Coastguard WorkerA parameter **SHOULD** be structured in a tree. Each parameter being a distinct
348*c33452fbSAndroid Build Coastguard Workertree leaf.
349*c33452fbSAndroid Build Coastguard Worker<why>Tree is a simple data structure that can be easily represented and is
350*c33452fbSAndroid Build Coastguard Workerenough to map underlined layers.</why>
351*c33452fbSAndroid Build Coastguard Worker
352*c33452fbSAndroid Build Coastguard Worker#### Identifier
353*c33452fbSAndroid Build Coastguard WorkerEach node of the tree **SHOULD** have its own identifier with the same
354*c33452fbSAndroid Build Coastguard Workercharacteristics (type, independence...) than a parameter.
355*c33452fbSAndroid Build Coastguard Worker<why>To represent the tree without treating the leaf nodes specifically.</why>
356*c33452fbSAndroid Build Coastguard Worker
357*c33452fbSAndroid Build Coastguard Worker
358*c33452fbSAndroid Build Coastguard Worker# Syncer
359*c33452fbSAndroid Build Coastguard Worker
360*c33452fbSAndroid Build Coastguard Worker## Philosophy
361*c33452fbSAndroid Build Coastguard Worker
362*c33452fbSAndroid Build Coastguard WorkerThe PF philosophy is to map the hardware characteristics to parameters.
363*c33452fbSAndroid Build Coastguard WorkerIn order to impact the hardware when parameters are modified, a hardware specific
364*c33452fbSAndroid Build Coastguard Workercode must be used.
365*c33452fbSAndroid Build Coastguard Worker
366*c33452fbSAndroid Build Coastguard WorkerSyncers are responsible for synchronizing the values of parameters to the underlined hardware.
367*c33452fbSAndroid Build Coastguard WorkerIe, it is the glue between hardware and parameters. It contains the code specific
368*c33452fbSAndroid Build Coastguard Workerto access an hardware.
369*c33452fbSAndroid Build Coastguard Worker
370*c33452fbSAndroid Build Coastguard WorkerThe aim of the PF is to keep this hardware specific code as light as possible.
371*c33452fbSAndroid Build Coastguard Worker
372*c33452fbSAndroid Build Coastguard Worker## Definition
373*c33452fbSAndroid Build Coastguard Worker
374*c33452fbSAndroid Build Coastguard Worker<dl>
375*c33452fbSAndroid Build Coastguard Worker<dt>Syncer<dt>
376*c33452fbSAndroid Build Coastguard Worker<dd>
377*c33452fbSAndroid Build Coastguard WorkerEntity that keeps synchronised PF parameters and their associated hardware.
378*c33452fbSAndroid Build Coastguard Worker</dd>
379*c33452fbSAndroid Build Coastguard Worker</dl>
380*c33452fbSAndroid Build Coastguard Worker
381*c33452fbSAndroid Build Coastguard Worker## Requirements
382*c33452fbSAndroid Build Coastguard Worker
383*c33452fbSAndroid Build Coastguard Worker### Mapping
384*c33452fbSAndroid Build Coastguard WorkerA syncer **MUST** be mapped to one or more parameters.
385*c33452fbSAndroid Build Coastguard Worker<why>The hardware minimal access may be bigger than one parameter.</why>
386*c33452fbSAndroid Build Coastguard Worker
387*c33452fbSAndroid Build Coastguard Worker### Uniqueness
388*c33452fbSAndroid Build Coastguard WorkerOne parameter **MUST NOT** be mapped to two or more syncer.
389*c33452fbSAndroid Build Coastguard WorkerIe: a parameter MUST be mapped to zero or one syncer.
390*c33452fbSAndroid Build Coastguard Worker<why>Which syncer should be responsible to retrieve the initial parameter value
391*c33452fbSAndroid Build Coastguard Workerif they are multiple per parameter?</why>
392*c33452fbSAndroid Build Coastguard Worker
393*c33452fbSAndroid Build Coastguard Worker### Read hardware
394*c33452fbSAndroid Build Coastguard WorkerA syncer **MUST** support retrieving the mapped parameters value from the mapped
395*c33452fbSAndroid Build Coastguard Workerhardware.
396*c33452fbSAndroid Build Coastguard Worker<why>to retrieve a parameter value at the start of the PF.</why>
397*c33452fbSAndroid Build Coastguard Worker
398*c33452fbSAndroid Build Coastguard Worker#### Write hardware
399*c33452fbSAndroid Build Coastguard WorkerA syncer **MUST** support setting the mapped parameters value to the mapped
400*c33452fbSAndroid Build Coastguard Workerhardware.
401*c33452fbSAndroid Build Coastguard Worker<why>to synchronise hardware on parameter change.</why>
402*c33452fbSAndroid Build Coastguard Worker
403*c33452fbSAndroid Build Coastguard Worker#### API
404*c33452fbSAndroid Build Coastguard WorkerThis API **MAY** be a packed parameter structure, following the C ABI without
405*c33452fbSAndroid Build Coastguard Workerpadding.
406*c33452fbSAndroid Build Coastguard Worker<note>This is what the reference implementation does.</note>
407*c33452fbSAndroid Build Coastguard Worker<unknown>TODO</unknown>
408*c33452fbSAndroid Build Coastguard Worker
409*c33452fbSAndroid Build Coastguard Worker## Parameter introspection
410*c33452fbSAndroid Build Coastguard WorkerThe syncer API **SHOULD** allow introspection of the mapped parameters.
411*c33452fbSAndroid Build Coastguard Worker<why>the parameter structure may be useful for the syncer to communicate with
412*c33452fbSAndroid Build Coastguard Workerthe hardware. For example a syncer might need each to know each associated
413*c33452fbSAndroid Build Coastguard Workerparameter type to send it to the hardware.</why>
414*c33452fbSAndroid Build Coastguard Worker
415*c33452fbSAndroid Build Coastguard Worker## Plugins
416*c33452fbSAndroid Build Coastguard Worker
417*c33452fbSAndroid Build Coastguard Worker - This formation is object oriented. Requirements should not require any programing paradigm.
418*c33452fbSAndroid Build Coastguard Worker - Is this section about syncer creation and builders too close to implementation ?
419*c33452fbSAndroid Build Coastguard Worker
420*c33452fbSAndroid Build Coastguard Worker### Definition
421*c33452fbSAndroid Build Coastguard WorkerThe PF creates syncer using syncer builder.
422*c33452fbSAndroid Build Coastguard Worker
423*c33452fbSAndroid Build Coastguard Worker### Requirements
424*c33452fbSAndroid Build Coastguard WorkerThe PF **MUST** be able to create syncers.
425*c33452fbSAndroid Build Coastguard Worker<why>To bind on the corresponding parameters.</why>
426*c33452fbSAndroid Build Coastguard Worker
427*c33452fbSAndroid Build Coastguard Worker### Identifier
428*c33452fbSAndroid Build Coastguard Worker
429*c33452fbSAndroid Build Coastguard Worker#### Syncer library
430*c33452fbSAndroid Build Coastguard WorkerAll syncers mapping to the same hardware **SHOULD** have their builders regrouped
431*c33452fbSAndroid Build Coastguard Workerin a syncer library.
432*c33452fbSAndroid Build Coastguard Worker<note>FIXME:
433*c33452fbSAndroid Build Coastguard Worker
434*c33452fbSAndroid Build Coastguard Worker - Is this syncer library concept not a definition ? Ie a syncer builder set.
435*c33452fbSAndroid Build Coastguard Worker - The concept is needed by other requirement but it does not stand by itself.
436*c33452fbSAndroid Build Coastguard Worker - Why is there a requirement of "same hardware" ?
437*c33452fbSAndroid Build Coastguard Worker      Is this not more a convention than a requirement ?
438*c33452fbSAndroid Build Coastguard Worker
439*c33452fbSAndroid Build Coastguard Worker</note>
440*c33452fbSAndroid Build Coastguard Worker<why>To be able to link a group of parameters and a given hardware.
441*c33452fbSAndroid Build Coastguard WorkerFor example all parameters that are mapped to sound card should be linked to a
442*c33452fbSAndroid Build Coastguard Workersound card syncer library. (Each parameter are then individually mapped to a specific syncer.)
443*c33452fbSAndroid Build Coastguard Worker</why>
444*c33452fbSAndroid Build Coastguard Worker
445*c33452fbSAndroid Build Coastguard Worker#### Syncer ID
446*c33452fbSAndroid Build Coastguard WorkerA syncer builder **MUST** have a unique identifier in its containing syncer
447*c33452fbSAndroid Build Coastguard Workerlibrary.
448*c33452fbSAndroid Build Coastguard Worker<why>To uniquely identify the syncer that should bind on parameters. Given that
449*c33452fbSAndroid Build Coastguard Workerthe syncer library has already been specified.</why>
450*c33452fbSAndroid Build Coastguard Worker
451*c33452fbSAndroid Build Coastguard Worker#### Library UID
452*c33452fbSAndroid Build Coastguard WorkerA syncer library **MUST** have a unique identifier in the host system.
453*c33452fbSAndroid Build Coastguard Worker<why>To identify the library associated to parameters.</why>
454*c33452fbSAndroid Build Coastguard Worker
455*c33452fbSAndroid Build Coastguard Worker### Loading
456*c33452fbSAndroid Build Coastguard Worker
457*c33452fbSAndroid Build Coastguard Worker#### DLL
458*c33452fbSAndroid Build Coastguard WorkerSyncer library or/and builder **MAY** be loaded from dynamically linked libraries
459*c33452fbSAndroid Build Coastguard Worker(called syncer plugins).
460*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
461*c33452fbSAndroid Build Coastguard Worker
462*c33452fbSAndroid Build Coastguard Worker#### Plugin entry point
463*c33452fbSAndroid Build Coastguard WorkerSuch syncer plugins **SHOULD** have an unique entry point that -- when called --
464*c33452fbSAndroid Build Coastguard Workershould register its payload (syncer library/builder) in the provided gatherer.
465*c33452fbSAndroid Build Coastguard Worker<note>This permit to merge multiple syncer libraries in one shared
466*c33452fbSAndroid Build Coastguard Workerlibrary.</note>
467*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
468*c33452fbSAndroid Build Coastguard Worker
469*c33452fbSAndroid Build Coastguard Worker#### Plugin interdependancies
470*c33452fbSAndroid Build Coastguard WorkerMultiple syncer plugins, may depend on each other. The PF should appropriately
471*c33452fbSAndroid Build Coastguard Workerhandle the case and not fail.
472*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation supports it.</unknown>
473*c33452fbSAndroid Build Coastguard Worker
474*c33452fbSAndroid Build Coastguard Worker## Mapping
475*c33452fbSAndroid Build Coastguard Worker### Definition
476*c33452fbSAndroid Build Coastguard Worker
477*c33452fbSAndroid Build Coastguard Worker<dl>
478*c33452fbSAndroid Build Coastguard Worker<dt>Virtual Parameter</dt>
479*c33452fbSAndroid Build Coastguard Worker<dd>
480*c33452fbSAndroid Build Coastguard WorkerA parameter not bound to a syncer.
481*c33452fbSAndroid Build Coastguard Worker(Todo: remove if not used in the requirements.)
482*c33452fbSAndroid Build Coastguard Worker</dd>
483*c33452fbSAndroid Build Coastguard Worker</dl>
484*c33452fbSAndroid Build Coastguard Worker
485*c33452fbSAndroid Build Coastguard Worker### Requirements
486*c33452fbSAndroid Build Coastguard Worker**TODO**:
487*c33452fbSAndroid Build Coastguard Worker - Plugins
488*c33452fbSAndroid Build Coastguard Worker - association builder <-> parameters
489*c33452fbSAndroid Build Coastguard Worker
490*c33452fbSAndroid Build Coastguard Worker## Sync
491*c33452fbSAndroid Build Coastguard Worker
492*c33452fbSAndroid Build Coastguard Worker### Sync on change
493*c33452fbSAndroid Build Coastguard WorkerSyncer **SHOULD** synchronise the mapped hardware on parameter change.
494*c33452fbSAndroid Build Coastguard Worker<why>To always keep synchronise the underlined hardware and the PF
495*c33452fbSAndroid Build Coastguard Workerparameters.</why>
496*c33452fbSAndroid Build Coastguard Worker
497*c33452fbSAndroid Build Coastguard Worker### Read hardware
498*c33452fbSAndroid Build Coastguard WorkerSyncer **SHOULD** retrieve parameter value from the hardware if no value has be
499*c33452fbSAndroid Build Coastguard Workerset since the PF start.
500*c33452fbSAndroid Build Coastguard Worker<note>This is usually implemented on PF start, initialize the parameter values
501*c33452fbSAndroid Build Coastguard Workerwith the mapped hardware current state.</note>
502*c33452fbSAndroid Build Coastguard Worker<why>To allow introspection of the hardware.</why>
503*c33452fbSAndroid Build Coastguard Worker
504*c33452fbSAndroid Build Coastguard Worker### Explicit sync
505*c33452fbSAndroid Build Coastguard WorkerA mode with synchronisation on client request **SHOULD** be supported.
506*c33452fbSAndroid Build Coastguard Worker<why>The user may want to group the synchronization of multiple parameters --
507*c33452fbSAndroid Build Coastguard Workerfor instance if a syncer contains more than 1 parameter -- in order to avoid
508*c33452fbSAndroid Build Coastguard Workerundesired intermediary states.</why>
509*c33452fbSAndroid Build Coastguard Worker
510*c33452fbSAndroid Build Coastguard Worker### Out of sync
511*c33452fbSAndroid Build Coastguard WorkerSyncers **MAY** report an 'out-of-sync' condition indicating that the hardware
512*c33452fbSAndroid Build Coastguard Workerparameter values are not (or no longer) reflecting the last values set by the
513*c33452fbSAndroid Build Coastguard WorkerParameter Framework.
514*c33452fbSAndroid Build Coastguard Worker<why>This can happen when the underlying hardware subsystem
515*c33452fbSAndroid Build Coastguard Workercrashes/reboots/...</why>
516*c33452fbSAndroid Build Coastguard Worker
517*c33452fbSAndroid Build Coastguard Worker#### Recovery
518*c33452fbSAndroid Build Coastguard WorkerWhen a syncer reports an out-of-sync condition, the PF **MUST** try to resync
519*c33452fbSAndroid Build Coastguard Workerthe hardware values.
520*c33452fbSAndroid Build Coastguard Worker
521*c33452fbSAndroid Build Coastguard Worker# Rule based dynamic abstraction
522*c33452fbSAndroid Build Coastguard Worker
523*c33452fbSAndroid Build Coastguard Worker## Philosophy
524*c33452fbSAndroid Build Coastguard Worker
525*c33452fbSAndroid Build Coastguard WorkerThe PF offers parameters mapped on hardware. This is a good but weak
526*c33452fbSAndroid Build Coastguard Workerabstraction as there is often a 1/1 relation between a parameter and the hardware
527*c33452fbSAndroid Build Coastguard Workerit maps. Ie: parameter abstract how to access hardware and what hardware but
528*c33452fbSAndroid Build Coastguard Workerare still hardware specific.
529*c33452fbSAndroid Build Coastguard Worker
530*c33452fbSAndroid Build Coastguard WorkerA PF offers a mechanism to abstract the parameters to a higher level concept.
531*c33452fbSAndroid Build Coastguard Worker
532*c33452fbSAndroid Build Coastguard WorkerThe goal is to hide numerous parameters and their dynamic values behind simple
533*c33452fbSAndroid Build Coastguard Workerand human friendly API.
534*c33452fbSAndroid Build Coastguard Worker
535*c33452fbSAndroid Build Coastguard WorkerIt works by grouping parameters with similar management and defining
536*c33452fbSAndroid Build Coastguard Workerconfigurations for each "scenario". These "scenario" are then given a priority
537*c33452fbSAndroid Build Coastguard Workerand a detection predicate. Configuration are applied when their associated
538*c33452fbSAndroid Build Coastguard Worker"scenario" is detected.
539*c33452fbSAndroid Build Coastguard Worker
540*c33452fbSAndroid Build Coastguard Worker"Scenario" are detected through arbitrary criterion provided by the PF host
541*c33452fbSAndroid Build Coastguard Worker(see below).
542*c33452fbSAndroid Build Coastguard Worker
543*c33452fbSAndroid Build Coastguard Worker## Definition
544*c33452fbSAndroid Build Coastguard Worker
545*c33452fbSAndroid Build Coastguard Worker<dl>
546*c33452fbSAndroid Build Coastguard Worker<dt>Configuration</dt>
547*c33452fbSAndroid Build Coastguard Worker<dd>
548*c33452fbSAndroid Build Coastguard WorkerSet of values for different parameters. A configuration **MUST NOT** contain 2
549*c33452fbSAndroid Build Coastguard Workervalues of the same parameter.
550*c33452fbSAndroid Build Coastguard Worker
551*c33452fbSAndroid Build Coastguard WorkerFor example, given a PF with 3 integer parameters A,B,C, a configuration can
552*c33452fbSAndroid Build Coastguard Workercontain:
553*c33452fbSAndroid Build Coastguard Worker
554*c33452fbSAndroid Build Coastguard Worker - 1 value: (A) or (B) or (C); or
555*c33452fbSAndroid Build Coastguard Worker - 2 values: (A,B) or (A,C) or (B,C); or
556*c33452fbSAndroid Build Coastguard Worker - 3 values: (A,B,C).
557*c33452fbSAndroid Build Coastguard Worker</dd>
558*c33452fbSAndroid Build Coastguard Worker
559*c33452fbSAndroid Build Coastguard Worker<dt>Rogue Parameter</dt>
560*c33452fbSAndroid Build Coastguard Worker<dd>
561*c33452fbSAndroid Build Coastguard WorkerA Parameter that is not contained by any configuration.
562*c33452fbSAndroid Build Coastguard Worker<dd>
563*c33452fbSAndroid Build Coastguard Worker</dl>
564*c33452fbSAndroid Build Coastguard Worker
565*c33452fbSAndroid Build Coastguard Worker## Configuration
566*c33452fbSAndroid Build Coastguard Worker
567*c33452fbSAndroid Build Coastguard Worker### Support
568*c33452fbSAndroid Build Coastguard WorkerA PF **MUST** offer configurations as described in the Definition chapter.
569*c33452fbSAndroid Build Coastguard Worker<note>rule based parameter engine does not manipulate directly values, it
570*c33452fbSAndroid Build Coastguard Workerapplies configuration on the parameters.</note>
571*c33452fbSAndroid Build Coastguard Worker<unknown>This is what the reference implementation does.</unknown>
572*c33452fbSAndroid Build Coastguard Worker
573*c33452fbSAndroid Build Coastguard Worker### Eligibility
574*c33452fbSAndroid Build Coastguard WorkerEach configuration **MUST** be associated with a predicate that condition its
575*c33452fbSAndroid Build Coastguard Workereligibility. A configuration with a predicate that evaluates to `true` is called
576*c33452fbSAndroid Build Coastguard Workeran "eligible configuration"
577*c33452fbSAndroid Build Coastguard Worker<why>This is what the reference implementation does.</why>
578*c33452fbSAndroid Build Coastguard Worker
579*c33452fbSAndroid Build Coastguard Worker### Default
580*c33452fbSAndroid Build Coastguard WorkerIt **SHOULD** be possible to express a predicate to always evaluates to `true`.
581*c33452fbSAndroid Build Coastguard WorkerIe: It *SHOULD* be possible to make a configuration always eligible.
582*c33452fbSAndroid Build Coastguard Worker<why>In order to have parameters set to constant values or have a fallback
583*c33452fbSAndroid Build Coastguard Workerconfiguration in a domain -- see below.</why>
584*c33452fbSAndroid Build Coastguard Worker
585*c33452fbSAndroid Build Coastguard Worker### Predicate implementation
586*c33452fbSAndroid Build Coastguard WorkerThe predicate **SHOULD** be a "selection criterion rule". See next chapter for a
587*c33452fbSAndroid Build Coastguard Workerdefinition.
588*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation uses a boolean expression based engine.</why>
589*c33452fbSAndroid Build Coastguard Worker
590*c33452fbSAndroid Build Coastguard Worker## Selection criterion
591*c33452fbSAndroid Build Coastguard Worker
592*c33452fbSAndroid Build Coastguard Worker### State uniqueness
593*c33452fbSAndroid Build Coastguard WorkerA selection criterion **MUST** have one, and only one, state at a given time.
594*c33452fbSAndroid Build Coastguard Worker
595*c33452fbSAndroid Build Coastguard Worker### State validity
596*c33452fbSAndroid Build Coastguard WorkerA selection criterion **MUST** have a always known immutable domain of definition.
597*c33452fbSAndroid Build Coastguard WorkerIe All the possible state that a selection criterion can take **MUST** be known
598*c33452fbSAndroid Build Coastguard Workerat all time.
599*c33452fbSAndroid Build Coastguard Worker<why>To be able to validate:\
600*c33452fbSAndroid Build Coastguard Worker - rules on start\
601*c33452fbSAndroid Build Coastguard Worker - state changes
602*c33452fbSAndroid Build Coastguard Worker</why>
603*c33452fbSAndroid Build Coastguard Worker
604*c33452fbSAndroid Build Coastguard Worker### State domain specification
605*c33452fbSAndroid Build Coastguard Worker#### Naive
606*c33452fbSAndroid Build Coastguard WorkerThe selection criterion possible states **MUST** be specifiable by directly a
607*c33452fbSAndroid Build Coastguard Workerstate set (`Input -> states == identity`)
608*c33452fbSAndroid Build Coastguard Worker<note>called **exclusive criterion**</note>
609*c33452fbSAndroid Build Coastguard Worker<note>An empty set is not allowed as the criterion could not have a state.</note>
610*c33452fbSAndroid Build Coastguard Worker<why>Any criterion can be created from this API.</why>
611*c33452fbSAndroid Build Coastguard Worker
612*c33452fbSAndroid Build Coastguard Worker#### Combination
613*c33452fbSAndroid Build Coastguard WorkerThe selection criterion possible states **SHOULD** be specifiable by a combination
614*c33452fbSAndroid Build Coastguard Workerof values
615*c33452fbSAndroid Build Coastguard Worker<note>combination in the [mathematical sense](https://en.wikipedia.org/wiki/Combination)
616*c33452fbSAndroid Build Coastguard Worker`"ab" -> ["", "a", "b", "ab"]`</note>
617*c33452fbSAndroid Build Coastguard Worker<note>called **inclusive criterion**</note>
618*c33452fbSAndroid Build Coastguard Worker<note>An empty value set is allowed as its combination -- a set containing the
619*c33452fbSAndroid Build Coastguard Workerempty set -- would not be empty. The empty set would be the only possible
620*c33452fbSAndroid Build Coastguard Workercriteria state.</note>
621*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation supports it.</why>
622*c33452fbSAndroid Build Coastguard Worker
623*c33452fbSAndroid Build Coastguard Worker### Criteria number
624*c33452fbSAndroid Build Coastguard WorkerThe PF **SHOULD NOT** limit the number of criteria.
625*c33452fbSAndroid Build Coastguard Worker
626*c33452fbSAndroid Build Coastguard Worker#### State number
627*c33452fbSAndroid Build Coastguard WorkerThe PF **SHOULD NOT** limit the number of possible states of any given criterion
628*c33452fbSAndroid Build Coastguard Worker<ko>The reference implementation only supports 32 values for an inclusive
629*c33452fbSAndroid Build Coastguard Workercriterion and 2^32 values for an exclusive criterion</ko>
630*c33452fbSAndroid Build Coastguard Worker
631*c33452fbSAndroid Build Coastguard Worker### Definitions
632*c33452fbSAndroid Build Coastguard Worker<dl>
633*c33452fbSAndroid Build Coastguard Worker<dt>Selection criterion rule</dt>
634*c33452fbSAndroid Build Coastguard Worker<dd>
635*c33452fbSAndroid Build Coastguard WorkerFunction (in the mathematical sense) that **MUST** given selection criteria
636*c33452fbSAndroid Build Coastguard Workerreturn a Boolean. Ie, a [predicate](https://en.wikipedia.org/wiki/Predicate_%28mathematical_logic%29).
637*c33452fbSAndroid Build Coastguard Worker</dd>
638*c33452fbSAndroid Build Coastguard Worker
639*c33452fbSAndroid Build Coastguard Worker<dt>Rule</dt>
640*c33452fbSAndroid Build Coastguard Worker<dd>
641*c33452fbSAndroid Build Coastguard WorkerA Boolean expression of Selection criterion rules.
642*c33452fbSAndroid Build Coastguard Worker<note>implementation only allows AND and OR combination</note>
643*c33452fbSAndroid Build Coastguard Worker<dd>
644*c33452fbSAndroid Build Coastguard Worker</dl>
645*c33452fbSAndroid Build Coastguard Worker
646*c33452fbSAndroid Build Coastguard Worker### Criterion changes
647*c33452fbSAndroid Build Coastguard Worker
648*c33452fbSAndroid Build Coastguard Worker#### Multiple criterion change atomicity
649*c33452fbSAndroid Build Coastguard WorkerThe API to change criterion values **MUST** allow atomicity regarding
650*c33452fbSAndroid Build Coastguard Workerconfiguration application. I.e. it **MUST** be possible to change multiple
651*c33452fbSAndroid Build Coastguard Workercriterion values without triggering a configuration application.
652*c33452fbSAndroid Build Coastguard Worker<why>Two criterion might have an excluding state. If configuration application
653*c33452fbSAndroid Build Coastguard Workerwas triggered after each criterion change this transitory incompatible state
654*c33452fbSAndroid Build Coastguard Workerwould impact the system.
655*c33452fbSAndroid Build Coastguard WorkerFor example 2 criterion `Tx` and `Rx` with 2 values `"on"` and `"off"` may have
656*c33452fbSAndroid Build Coastguard Workeran incompatible state `Tx = Rx = "on"`. Ie this state is unspecified and the
657*c33452fbSAndroid Build Coastguard Workerinference engine would gave unknown result.
658*c33452fbSAndroid Build Coastguard Worker\
659*c33452fbSAndroid Build Coastguard WorkerWhen going: \
660*c33452fbSAndroid Build Coastguard Worker - from `Tx = "on" and Rx = "on"` (state 1) \
661*c33452fbSAndroid Build Coastguard Worker - to `Tx = "off" and Rx = "off"` (state 2) \
662*c33452fbSAndroid Build Coastguard Worker<!-- FIXME: why are list closing the why block ?  -->
663*c33452fbSAndroid Build Coastguard Workera transitory state `Tx = "on" and Rx = "on"` may be reached. Nevertheless
664*c33452fbSAndroid Build Coastguard Workerthe inference engine must not be run on such. There must be a way to go
665*c33452fbSAndroid Build Coastguard Workerfrom one state 1 to state 2 without triggering configuration application.
666*c33452fbSAndroid Build Coastguard Worker</why>
667*c33452fbSAndroid Build Coastguard Worker
668*c33452fbSAndroid Build Coastguard Worker### Rules
669*c33452fbSAndroid Build Coastguard Worker
670*c33452fbSAndroid Build Coastguard WorkerIt **MUST** always be able to express a selection criterion rule from a given
671*c33452fbSAndroid Build Coastguard Workerselection criterion state.
672*c33452fbSAndroid Build Coastguard WorkerI.e.: a criteria **MUST** always have a state that can be matched by a rule.
673*c33452fbSAndroid Build Coastguard Worker<why>If no rules can be formulated from a criterion state,
674*c33452fbSAndroid Build Coastguard Workerthe hardware can not be abstracted in this state witch defeats the PF purpose.</why>
675*c33452fbSAndroid Build Coastguard Worker
676*c33452fbSAndroid Build Coastguard WorkerParameter values change **SHOULD** be selected by Rules.
677*c33452fbSAndroid Build Coastguard Worker<why>A rule based inference engine has been chosen based on implementation and
678*c33452fbSAndroid Build Coastguard Workerconfiguration ease</why>
679*c33452fbSAndroid Build Coastguard Worker
680*c33452fbSAndroid Build Coastguard Worker## Domains
681*c33452fbSAndroid Build Coastguard Worker
682*c33452fbSAndroid Build Coastguard Worker### Definition
683*c33452fbSAndroid Build Coastguard Worker<dl>
684*c33452fbSAndroid Build Coastguard Worker<dt>Domain</dt>
685*c33452fbSAndroid Build Coastguard Worker<dd>
686*c33452fbSAndroid Build Coastguard WorkerOrdered set of configuration, all of which contain the values for the
687*c33452fbSAndroid Build Coastguard Workersame parameters.
688*c33452fbSAndroid Build Coastguard Worker</dd>
689*c33452fbSAndroid Build Coastguard Worker</dl>
690*c33452fbSAndroid Build Coastguard Worker
691*c33452fbSAndroid Build Coastguard Worker### Philosophy
692*c33452fbSAndroid Build Coastguard Worker
693*c33452fbSAndroid Build Coastguard WorkerWhen creating configurations for parameters, a pattern emerges.
694*c33452fbSAndroid Build Coastguard WorkerSome parameters are naturally grouping together. Ie changing on the same predicates.
695*c33452fbSAndroid Build Coastguard Worker
696*c33452fbSAndroid Build Coastguard WorkerWithout carefully crafting configuration predicates for mutual exclusivity,
697*c33452fbSAndroid Build Coastguard Workermultiples configuration of the same parameter could be eligible on the same
698*c33452fbSAndroid Build Coastguard Workercriterion state. This would lead to an ambiguity: which configuration should be applied.
699*c33452fbSAndroid Build Coastguard Worker
700*c33452fbSAndroid Build Coastguard WorkerMultiple solution could be imagine like:
701*c33452fbSAndroid Build Coastguard Worker - ask to the client/user
702*c33452fbSAndroid Build Coastguard Worker - having configuration predicate mutual exclusive
703*c33452fbSAndroid Build Coastguard Worker - choose randomly
704*c33452fbSAndroid Build Coastguard Worker - group configuration applicable on the same in a priority ordered set
705*c33452fbSAndroid Build Coastguard Worker
706*c33452fbSAndroid Build Coastguard WorkerThe domains this specification recommend is this last solution.
707*c33452fbSAndroid Build Coastguard WorkerIt has been chosen as the recommended solution (just like parameter tree)
708*c33452fbSAndroid Build Coastguard Workerbecause it is a simple solution and is implemented in the reference implementation.
709*c33452fbSAndroid Build Coastguard Worker
710*c33452fbSAndroid Build Coastguard WorkerThe constraint of this solution is that a configuration can no longer be shared
711*c33452fbSAndroid Build Coastguard Workerbetween domains. For example a global default configuration can not exist.
712*c33452fbSAndroid Build Coastguard WorkerIt must be split up for each domain.
713*c33452fbSAndroid Build Coastguard Worker
714*c33452fbSAndroid Build Coastguard WorkerThis choice also force parameters to be independently accessible.
715*c33452fbSAndroid Build Coastguard Worker
716*c33452fbSAndroid Build Coastguard Worker### Requirement
717*c33452fbSAndroid Build Coastguard Worker
718*c33452fbSAndroid Build Coastguard Worker#### Configuration application ambiguity
719*c33452fbSAndroid Build Coastguard WorkerThere **MUST** be a mechanism to avoid ambiguity on multiple configuration eligibility
720*c33452fbSAndroid Build Coastguard Workerfor the same parameter.
721*c33452fbSAndroid Build Coastguard Worker<why>Applying multiple configurations would leave the parameters in an unknown state.</why>
722*c33452fbSAndroid Build Coastguard Worker
723*c33452fbSAndroid Build Coastguard Worker#### Domain support
724*c33452fbSAndroid Build Coastguard WorkerEach configuration **SHOULD** be in a "domain" (see Definition chapter).
725*c33452fbSAndroid Build Coastguard Worker<why>Domains are mostly a way to define the priority of configuration application
726*c33452fbSAndroid Build Coastguard Workerfor some parameters.</why>
727*c33452fbSAndroid Build Coastguard Worker<ko>It is not a MUST because this goal could also be achieve with (for
728*c33452fbSAndroid Build Coastguard Workerexample) global configurations and per parameter priority. It is not a MAY
729*c33452fbSAndroid Build Coastguard Workerbecause the reference implementation uses domains.</ko>
730*c33452fbSAndroid Build Coastguard Worker
731*c33452fbSAndroid Build Coastguard Worker#### Configuration priority
732*c33452fbSAndroid Build Coastguard WorkerIf multiple configuration are eligible, the first one **MUST** be applied.
733*c33452fbSAndroid Build Coastguard Worker<why>If multiple configuration are eligible, there must be a way to discriminate
734*c33452fbSAndroid Build Coastguard Workerthem. The order was arbitrary chosen.
735*c33452fbSAndroid Build Coastguard WorkerSee the domain philosophy section for more information about this choice.</why>
736*c33452fbSAndroid Build Coastguard Worker
737*c33452fbSAndroid Build Coastguard Worker#### Lazy application
738*c33452fbSAndroid Build Coastguard WorkerIf no configuration is eligible, no configuration **MUST** be applied.
739*c33452fbSAndroid Build Coastguard Worker<note>It means that if none of the configurations is eligible, none is applied.
740*c33452fbSAndroid Build Coastguard WorkerThis also mean that no function can be defined between criteria and states.
741*c33452fbSAndroid Build Coastguard WorkerI.e.: parameter values MAY depend on previous selection criterion states.</note>
742*c33452fbSAndroid Build Coastguard Worker<why>This is what the reference implementation does.</why>
743*c33452fbSAndroid Build Coastguard Worker
744*c33452fbSAndroid Build Coastguard Worker#### Sequence indifference
745*c33452fbSAndroid Build Coastguard WorkerParameter set and get order MUST not change the final state.
746*c33452fbSAndroid Build Coastguard Worker<why>Their is no way to order such access if the parameters are from different domains.</why>
747*c33452fbSAndroid Build Coastguard Worker
748*c33452fbSAndroid Build Coastguard Worker#### Sequence aware domain
749*c33452fbSAndroid Build Coastguard WorkerDomains **MAY** be sequence aware. Such domains update their associated
750*c33452fbSAndroid Build Coastguard Workerparameters in a specific, predictable and configurable order.
751*c33452fbSAndroid Build Coastguard Worker<ko>The reference application supports it.</ko>
752*c33452fbSAndroid Build Coastguard Worker<why>Some parameters might require specific ordering on set.
753*c33452fbSAndroid Build Coastguard WorkerThis is contradictory with the fact that parameters MUST be accessed independently.</why>
754*c33452fbSAndroid Build Coastguard Worker
755*c33452fbSAndroid Build Coastguard Worker# (de)serialization
756*c33452fbSAndroid Build Coastguard Worker
757*c33452fbSAndroid Build Coastguard Worker## Philosophy
758*c33452fbSAndroid Build Coastguard WorkerSerialization and deserialization are meant to support destruction recovery and
759*c33452fbSAndroid Build Coastguard Workerconfiguration deployment.
760*c33452fbSAndroid Build Coastguard Worker
761*c33452fbSAndroid Build Coastguard WorkerThese are the same requirements than for a database, it needs to be able to save
762*c33452fbSAndroid Build Coastguard Workerits state and restore for backup, deployment, reboot...
763*c33452fbSAndroid Build Coastguard Worker
764*c33452fbSAndroid Build Coastguard Worker## Definition
765*c33452fbSAndroid Build Coastguard WorkerPF data includes:
766*c33452fbSAndroid Build Coastguard Worker
767*c33452fbSAndroid Build Coastguard Worker- parameters tree
768*c33452fbSAndroid Build Coastguard Worker- configurations:
769*c33452fbSAndroid Build Coastguard Worker    - selection rule
770*c33452fbSAndroid Build Coastguard Worker    - parameter/value couples
771*c33452fbSAndroid Build Coastguard Worker- domain:
772*c33452fbSAndroid Build Coastguard Worker    - list of associated configurations
773*c33452fbSAndroid Build Coastguard Worker    - order of priority
774*c33452fbSAndroid Build Coastguard Worker
775*c33452fbSAndroid Build Coastguard Worker## Requirement
776*c33452fbSAndroid Build Coastguard Worker
777*c33452fbSAndroid Build Coastguard Worker### Deserializable
778*c33452fbSAndroid Build Coastguard WorkerThe PF data **MUST** be deserializable.
779*c33452fbSAndroid Build Coastguard Worker<why>Otherwise a PF instance could only be created empty and then be filled by
780*c33452fbSAndroid Build Coastguard Workerthe tuning interface. The reference implementation supports it.</why>
781*c33452fbSAndroid Build Coastguard Worker
782*c33452fbSAndroid Build Coastguard Worker### Deserializable from a file
783*c33452fbSAndroid Build Coastguard WorkerThe PF data **SHOULD** be deserializable from a config file.
784*c33452fbSAndroid Build Coastguard Worker<why>This is usually how program configuration are stored. The reference
785*c33452fbSAndroid Build Coastguard Workerimplementation supports it.</why>
786*c33452fbSAndroid Build Coastguard Worker
787*c33452fbSAndroid Build Coastguard Worker### Serializable
788*c33452fbSAndroid Build Coastguard WorkerThe PF data **SHOULD** be serializable.
789*c33452fbSAndroid Build Coastguard Worker<why>In order to save a PF instance state and restore it later. This achieve
790*c33452fbSAndroid Build Coastguard Workerdestruction recovery. The reference implementation supports it.</why>
791*c33452fbSAndroid Build Coastguard Worker
792*c33452fbSAndroid Build Coastguard Worker### (De)Serialization of individual data
793*c33452fbSAndroid Build Coastguard WorkerThe PF data **SHOULD** be serializable/deserializable by parts.
794*c33452fbSAndroid Build Coastguard Worker<why>For easier configuration management: for versioning; for selecting only wanted parts of a
795*c33452fbSAndroid Build Coastguard Workercomplete configuration.</why>
796*c33452fbSAndroid Build Coastguard Worker
797*c33452fbSAndroid Build Coastguard Worker### Serialization format
798*c33452fbSAndroid Build Coastguard Worker**TODO**: XML ?
799*c33452fbSAndroid Build Coastguard Worker
800*c33452fbSAndroid Build Coastguard Worker### Implementation
801*c33452fbSAndroid Build Coastguard WorkerSyncer build and syncer library identifiers **SHOULD** be strings.
802*c33452fbSAndroid Build Coastguard Worker<unknown>The reference application does so.</unknown>
803*c33452fbSAndroid Build Coastguard Worker
804*c33452fbSAndroid Build Coastguard Worker# Post mortem debug
805*c33452fbSAndroid Build Coastguard WorkerA PF **MAY** save all data needed to replay it's state evolution.
806*c33452fbSAndroid Build Coastguard Worker<note>Eg: log criterion change, configuration application, parameter
807*c33452fbSAndroid Build Coastguard Workerexternal change.
808*c33452fbSAndroid Build Coastguard Worker
809*c33452fbSAndroid Build Coastguard WorkerThis is implementing by logging events by the reference implementation.</note>
810*c33452fbSAndroid Build Coastguard Worker<why>In order for the user to debug the user configuration after a bug occurred (post mortem or rare bug).
811*c33452fbSAndroid Build Coastguard WorkerThis is kind of like the bash -x feature.
812*c33452fbSAndroid Build Coastguard Worker</why>
813*c33452fbSAndroid Build Coastguard Worker
814*c33452fbSAndroid Build Coastguard Worker# Introspection
815*c33452fbSAndroid Build Coastguard Worker## Philosophy
816*c33452fbSAndroid Build Coastguard WorkerIn order to debug the user configuration, allow introspection of PF data at runtime.
817*c33452fbSAndroid Build Coastguard WorkerAs data is meant to be displayed to user, lots are requirements are towards
818*c33452fbSAndroid Build Coastguard Workerpretty printing PF data.
819*c33452fbSAndroid Build Coastguard Worker
820*c33452fbSAndroid Build Coastguard Worker## Requirements
821*c33452fbSAndroid Build Coastguard Worker
822*c33452fbSAndroid Build Coastguard Worker### Support
823*c33452fbSAndroid Build Coastguard WorkerUser **SHOULD** be able to inspect PF data.
824*c33452fbSAndroid Build Coastguard Worker<why>To offer run time debugging.
825*c33452fbSAndroid Build Coastguard WorkerThis includes: \
826*c33452fbSAndroid Build Coastguard Worker- listing \
827*c33452fbSAndroid Build Coastguard Worker\ \ \ \ + domains\
828*c33452fbSAndroid Build Coastguard Worker\ \ \ \ + configurations of a domains\
829*c33452fbSAndroid Build Coastguard Worker\ \ \ \ + parameters\
830*c33452fbSAndroid Build Coastguard Worker\ \ \ \ + a domain's associated parameters\
831*c33452fbSAndroid Build Coastguard Worker- getting their properties. Including:\
832*c33452fbSAndroid Build Coastguard Worker\ \ \ \ + parameters values, min, max, size...
833*c33452fbSAndroid Build Coastguard Worker</why>
834*c33452fbSAndroid Build Coastguard Worker
835*c33452fbSAndroid Build Coastguard Worker### Pretty print
836*c33452fbSAndroid Build Coastguard WorkerPF **MAY** offer pretty print of data. Including:
837*c33452fbSAndroid Build Coastguard Worker
838*c33452fbSAndroid Build Coastguard Worker- printing parameter value in decimal
839*c33452fbSAndroid Build Coastguard Worker    <why>For human readability</why>
840*c33452fbSAndroid Build Coastguard Worker- pretty print parameter tree (such as the Unix tree command for files)
841*c33452fbSAndroid Build Coastguard Worker    <why>In order to ease runtime debug.</why>
842*c33452fbSAndroid Build Coastguard Worker
843*c33452fbSAndroid Build Coastguard Worker### Rogue parameter
844*c33452fbSAndroid Build Coastguard WorkerUsers **SHOULD** be able to modify rogue parameters through the native API at
845*c33452fbSAndroid Build Coastguard Workerall time.
846*c33452fbSAndroid Build Coastguard Worker<why>Otherwise, a rogue parameter is of no use.</why>
847*c33452fbSAndroid Build Coastguard Worker<ko>In the reference implementation, under certain conditions, this is not
848*c33452fbSAndroid Build Coastguard Workerpossible (tuning mode)</ko>
849*c33452fbSAndroid Build Coastguard Worker
850*c33452fbSAndroid Build Coastguard Worker### Parameter Identifiers
851*c33452fbSAndroid Build Coastguard Worker
852*c33452fbSAndroid Build Coastguard Worker#### Support
853*c33452fbSAndroid Build Coastguard WorkerEvery parameter **MUST** have an identifier that uniquely identifies it.
854*c33452fbSAndroid Build Coastguard Worker<why>to identify a parameter outside the framework</why>
855*c33452fbSAndroid Build Coastguard Worker
856*c33452fbSAndroid Build Coastguard Worker#### String
857*c33452fbSAndroid Build Coastguard WorkerThis identifier **SHOULD** be a string.
858*c33452fbSAndroid Build Coastguard Worker<why>So that a human user can identify a parameter with ease.</why>
859*c33452fbSAndroid Build Coastguard Worker
860*c33452fbSAndroid Build Coastguard Worker#### Determinism
861*c33452fbSAndroid Build Coastguard WorkerTwo PF instances with the same parameters **MUST** have the same identifier for
862*c33452fbSAndroid Build Coastguard Workerthose parameters.
863*c33452fbSAndroid Build Coastguard WorkerI.e. this identifier should be the same across all instances with the same
864*c33452fbSAndroid Build Coastguard Workerconfiguration.
865*c33452fbSAndroid Build Coastguard Worker<why>Persistence of parameter identifier across PF instances with the same
866*c33452fbSAndroid Build Coastguard Workerconfiguration. To identify parameters independently of the host machine and PF
867*c33452fbSAndroid Build Coastguard Workerinstance</why>
868*c33452fbSAndroid Build Coastguard Worker
869*c33452fbSAndroid Build Coastguard Worker#### Tree path
870*c33452fbSAndroid Build Coastguard WorkerThe identifier of each node of a parameter tree **SHOULD** be a combination of its
871*c33452fbSAndroid Build Coastguard Workerparents. More specifically, if the identifier is a string it **SHOULD** be
872*c33452fbSAndroid Build Coastguard Workerformated in a similar way as a file system path. E.g. `/root/child1/4/parameter1`.
873*c33452fbSAndroid Build Coastguard Worker<why>Usual syntax to address trees.</why>
874*c33452fbSAndroid Build Coastguard Worker
875*c33452fbSAndroid Build Coastguard Worker
876*c33452fbSAndroid Build Coastguard Worker# Tuning
877*c33452fbSAndroid Build Coastguard Worker
878*c33452fbSAndroid Build Coastguard Worker## Definition
879*c33452fbSAndroid Build Coastguard Worker
880*c33452fbSAndroid Build Coastguard Worker<dl>
881*c33452fbSAndroid Build Coastguard Worker<dt>Tuning</dt>
882*c33452fbSAndroid Build Coastguard Worker<dd>
883*c33452fbSAndroid Build Coastguard WorkerTuning is the ability to modify the PF data structure at runtime.
884*c33452fbSAndroid Build Coastguard Worker</dd>
885*c33452fbSAndroid Build Coastguard Worker</dl>
886*c33452fbSAndroid Build Coastguard Worker
887*c33452fbSAndroid Build Coastguard Worker<note>Is this naming "Tuning" not too audio oriented.</note>
888*c33452fbSAndroid Build Coastguard Worker
889*c33452fbSAndroid Build Coastguard Worker## Philosophy
890*c33452fbSAndroid Build Coastguard Worker
891*c33452fbSAndroid Build Coastguard WorkerAs the PF might model a complex system with its dynamic parameter value engine
892*c33452fbSAndroid Build Coastguard Worker(rule based in the default implementation), its behaviour might be hard to
893*c33452fbSAndroid Build Coastguard Workerunderstand and should be easily modified not correct.
894*c33452fbSAndroid Build Coastguard Worker
895*c33452fbSAndroid Build Coastguard WorkerTo address this need, a fast modify-update-test cycle should be possible.
896*c33452fbSAndroid Build Coastguard Worker
897*c33452fbSAndroid Build Coastguard Worker## Requirements
898*c33452fbSAndroid Build Coastguard Worker
899*c33452fbSAndroid Build Coastguard Worker### Inference engine
900*c33452fbSAndroid Build Coastguard WorkerUsers **SHOULD** be able to modify the PF inference engine behaviour (rules,
901*c33452fbSAndroid Build Coastguard Workerconfiguration...) with minimal effort.
902*c33452fbSAndroid Build Coastguard Worker<why>To enable a fast modify-update-test cycle during tuning.
903*c33452fbSAndroid Build Coastguard WorkerThis usually mean avoiding for the user to: \
904*c33452fbSAndroid Build Coastguard Worker - recompile \
905*c33452fbSAndroid Build Coastguard Worker - restart the host process/service
906*c33452fbSAndroid Build Coastguard Worker</why>
907*c33452fbSAndroid Build Coastguard Worker
908*c33452fbSAndroid Build Coastguard Worker<note>No requirement is made on the persistence of those changes, they may or
909*c33452fbSAndroid Build Coastguard Workermay not disappear on PF restart. This could be implemented in several way, for
910*c33452fbSAndroid Build Coastguard Workerexample:
911*c33452fbSAndroid Build Coastguard Worker
912*c33452fbSAndroid Build Coastguard Worker- exposed in the PF API
913*c33452fbSAndroid Build Coastguard Worker- changing a config file and sending a signal to the PF
914*c33452fbSAndroid Build Coastguard Worker- providing a IPC
915*c33452fbSAndroid Build Coastguard Worker- directly modifying the memory
916*c33452fbSAndroid Build Coastguard Worker
917*c33452fbSAndroid Build Coastguard Worker</note>
918*c33452fbSAndroid Build Coastguard Worker
919*c33452fbSAndroid Build Coastguard Worker### Native api
920*c33452fbSAndroid Build Coastguard WorkerTuning **SHOULD** be possible from the PF native API.
921*c33452fbSAndroid Build Coastguard Worker<why>In order to let the host system implement its own tuning mechanism.</why>
922*c33452fbSAndroid Build Coastguard Worker
923*c33452fbSAndroid Build Coastguard Worker### Parameter overwriting
924*c33452fbSAndroid Build Coastguard WorkerUsers **SHOULD** be able to modify the parameter values at any time.
925*c33452fbSAndroid Build Coastguard WorkerThis change **SHOULD NOT** be overwritten without a user action.
926*c33452fbSAndroid Build Coastguard Worker<note>User overwritten user action could be a log out, leaving some tuning mode,
927*c33452fbSAndroid Build Coastguard Workerforcing an inference engine update...</note>
928*c33452fbSAndroid Build Coastguard Worker<why>Even if a parameter is managed by the inference engine, it often is useful
929*c33452fbSAndroid Build Coastguard Worker(test, debugging) to overwrite its value temporally.</why>
930*c33452fbSAndroid Build Coastguard Worker
931*c33452fbSAndroid Build Coastguard Worker### Disabling
932*c33452fbSAndroid Build Coastguard WorkerA PF tuning capability **MAY** be disabled in a context where no tuning is needed.
933*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation does so (phone end users can not change the
934*c33452fbSAndroid Build Coastguard Workertuning).</why>
935*c33452fbSAndroid Build Coastguard Worker
936*c33452fbSAndroid Build Coastguard Worker# Command line interface
937*c33452fbSAndroid Build Coastguard Worker<ko>Is this not an implementation detail? Does a client really needs it?</ko>
938*c33452fbSAndroid Build Coastguard Worker
939*c33452fbSAndroid Build Coastguard Worker## Support
940*c33452fbSAndroid Build Coastguard WorkerThe PF **MAY** offer a command line interface that binds to its IPC.
941*c33452fbSAndroid Build Coastguard Worker<why>To have a reference way to interact with a PF without implementing its IPC
942*c33452fbSAndroid Build Coastguard Workerprotocol.</why>
943*c33452fbSAndroid Build Coastguard Worker<note>This requirement is fulfilled by remote-processor and remote-command on the reference implementation.</note>
944*c33452fbSAndroid Build Coastguard Worker
945*c33452fbSAndroid Build Coastguard Worker## Introspection & tunning
946*c33452fbSAndroid Build Coastguard WorkerThis command line interface **SHOULD** support all tuning and introspection ability.
947*c33452fbSAndroid Build Coastguard Worker<why>In order to be used in scripting and live tuning/debugging on an embedded
948*c33452fbSAndroid Build Coastguard Workersystem.</why>
949*c33452fbSAndroid Build Coastguard Worker
950*c33452fbSAndroid Build Coastguard Worker## Auto completion
951*c33452fbSAndroid Build Coastguard WorkerThis command line interface **MAY** offer argument auto completion.
952*c33452fbSAndroid Build Coastguard Worker<why>Is more user friendly.</why>
953*c33452fbSAndroid Build Coastguard Worker
954*c33452fbSAndroid Build Coastguard Worker# Bindings
955*c33452fbSAndroid Build Coastguard Worker
956*c33452fbSAndroid Build Coastguard Worker## C
957*c33452fbSAndroid Build Coastguard WorkerThe PF **SHOULD** expose its API in C.
958*c33452fbSAndroid Build Coastguard Worker<why>The PF aims to be a hardware abstraction thus middle ware which is often
959*c33452fbSAndroid Build Coastguard Workerwritten in C or a language compatible with C. Virtually all programing language
960*c33452fbSAndroid Build Coastguard Workersupport C Foreign Procedure Call, having a C API ease integration whichever the
961*c33452fbSAndroid Build Coastguard Workerhost language is.</why>
962*c33452fbSAndroid Build Coastguard Worker
963*c33452fbSAndroid Build Coastguard Worker## Programing language
964*c33452fbSAndroid Build Coastguard WorkerThe PF **MAY** expose its API to multiple programing language.
965*c33452fbSAndroid Build Coastguard Worker<unknown>The reference implementation has python bindings.</unknown>
966*c33452fbSAndroid Build Coastguard Worker
967*c33452fbSAndroid Build Coastguard Worker# Performance
968*c33452fbSAndroid Build Coastguard Worker
969*c33452fbSAndroid Build Coastguard WorkerThe reference Parameter Framework implementation is mainly intended for use
970*c33452fbSAndroid Build Coastguard Workerin consumer electronics such as smartphones and tablets. Such platforms are
971*c33452fbSAndroid Build Coastguard Workeroften referred to as "embedded" platforms but their capacity today is so huge in
972*c33452fbSAndroid Build Coastguard Workerterms of both computing and memory that they can be considered as small personal
973*c33452fbSAndroid Build Coastguard Workercomputers.
974*c33452fbSAndroid Build Coastguard Worker
975*c33452fbSAndroid Build Coastguard WorkerMoreover, since one of the Parameter Framework's primary feature is to implement
976*c33452fbSAndroid Build Coastguard Workerstorage of
977*c33452fbSAndroid Build Coastguard Worker
978*c33452fbSAndroid Build Coastguard Worker - hardware description
979*c33452fbSAndroid Build Coastguard Worker - settings
980*c33452fbSAndroid Build Coastguard Worker
981*c33452fbSAndroid Build Coastguard Workerits memory footprint largely depends on how many such items are stored.
982*c33452fbSAndroid Build Coastguard Worker
983*c33452fbSAndroid Build Coastguard WorkerFor those reasons, there are no performance requirements imposed on the
984*c33452fbSAndroid Build Coastguard Workerarchitecture. Performance considerations are left to the implementation of the
985*c33452fbSAndroid Build Coastguard WorkerParameter Framework and/or the client and/or the build chain.
986*c33452fbSAndroid Build Coastguard Worker
987*c33452fbSAndroid Build Coastguard Worker# Next
988*c33452fbSAndroid Build Coastguard Worker
989*c33452fbSAndroid Build Coastguard Worker<ko>
990*c33452fbSAndroid Build Coastguard WorkerThe following requirements are not implemented in the reference implementation
991*c33452fbSAndroid Build Coastguard Workerand are to be considered draft.
992*c33452fbSAndroid Build Coastguard Worker</ko>
993*c33452fbSAndroid Build Coastguard Worker
994*c33452fbSAndroid Build Coastguard Worker## Multi OS
995*c33452fbSAndroid Build Coastguard WorkerPF **MAY** support at least:
996*c33452fbSAndroid Build Coastguard Worker
997*c33452fbSAndroid Build Coastguard Worker - Linux (and Android)
998*c33452fbSAndroid Build Coastguard Worker - Windows
999*c33452fbSAndroid Build Coastguard Worker - Mac OSX
1000*c33452fbSAndroid Build Coastguard Worker
1001*c33452fbSAndroid Build Coastguard Worker<why>As the reference PF implementation leaves its original Android environment,
1002*c33452fbSAndroid Build Coastguard Workerneeds emerge to use it on other platform.</why>
1003*c33452fbSAndroid Build Coastguard Worker
1004*c33452fbSAndroid Build Coastguard Worker## Tuning
1005*c33452fbSAndroid Build Coastguard Worker### Get and set multiple parameter values in one request
1006*c33452fbSAndroid Build Coastguard Worker#### Atomicity
1007*c33452fbSAndroid Build Coastguard WorkerWhen setting multiple parameters from one client request,
1008*c33452fbSAndroid Build Coastguard Workerand when one or more parameter value is invalid (eg. out of range),
1009*c33452fbSAndroid Build Coastguard Workerno parameter **SHOULD** be set.
1010*c33452fbSAndroid Build Coastguard WorkerEg: an invalid request to change parameters **SHOULD** not impact the parameters
1011*c33452fbSAndroid Build Coastguard Workervalues nor the subsystems.
1012*c33452fbSAndroid Build Coastguard Worker<note>This may be implemented by first checking parameters validity
1013*c33452fbSAndroid Build Coastguard Workerbefore setting them, or implementing a rollback mechanism, or any other way.</note>
1014*c33452fbSAndroid Build Coastguard Worker<why>To provide parameter mutation atomicity to the client.
1015*c33452fbSAndroid Build Coastguard WorkerThis is especially important if the client wants to implement parameter consistency.
1016*c33452fbSAndroid Build Coastguard WorkerEg: let two parameters have excluding values,
1017*c33452fbSAndroid Build Coastguard Workerif a transaction fail after the first parameter is set but not the second,
1018*c33452fbSAndroid Build Coastguard Workerthe excluding constraint may be violated.
1019*c33452fbSAndroid Build Coastguard WorkerIt also usefull for the client to know the state of the parameters
1020*c33452fbSAndroid Build Coastguard Workerafter a parameter set without having to query the PF.</why>
1021*c33452fbSAndroid Build Coastguard Worker
1022*c33452fbSAndroid Build Coastguard Worker#### Access parameters as Xml
1023*c33452fbSAndroid Build Coastguard WorkerGetting and setting the content of one or more ([one, all]) parameters **SHOULD**
1024*c33452fbSAndroid Build Coastguard Workerbe possible in xml.
1025*c33452fbSAndroid Build Coastguard Worker<why>For performance reason. Tools often need to update multiple parameter
1026*c33452fbSAndroid Build Coastguard Workerand having one call per parameter is too slow. (benchmark ?).
1027*c33452fbSAndroid Build Coastguard WorkerThis feature permit the client to save and restore from an external database parameter
1028*c33452fbSAndroid Build Coastguard Workervalues a la `alsa.state`.</why>
1029*c33452fbSAndroid Build Coastguard Worker
1030*c33452fbSAndroid Build Coastguard Worker#### Access parameters as binary
1031*c33452fbSAndroid Build Coastguard WorkerThe PF host API **SHOULD** expose parameter values with the same API syncer use.
1032*c33452fbSAndroid Build Coastguard Worker<why>The current reference implementation abstracts the memory layout of
1033*c33452fbSAndroid Build Coastguard Workerparameters. This memory layout is specified in the parameter structure thus
1034*c33452fbSAndroid Build Coastguard Workeris known by the client.</why>
1035*c33452fbSAndroid Build Coastguard Worker
1036*c33452fbSAndroid Build Coastguard Worker## Stage and commit Sync
1037*c33452fbSAndroid Build Coastguard WorkerExplicit sync **SHOULD** only sync parameters which values were updated since last sync.
1038*c33452fbSAndroid Build Coastguard Worker<why>For performance reason or when an hardware does not support certain
1039*c33452fbSAndroid Build Coastguard Workertransition state, manual parameter synchronisation is requested.
1040*c33452fbSAndroid Build Coastguard Worker
1041*c33452fbSAndroid Build Coastguard WorkerSync request was implemented in the reference implementation by syncing all
1042*c33452fbSAndroid Build Coastguard Workerparameters, including the one that were not changed since last sync.
1043*c33452fbSAndroid Build Coastguard Worker
1044*c33452fbSAndroid Build Coastguard WorkerFor performance reason only the changed parameters should be send to hardware.</why>
1045*c33452fbSAndroid Build Coastguard Worker
1046*c33452fbSAndroid Build Coastguard Worker
1047*c33452fbSAndroid Build Coastguard Worker## Structured api API
1048*c33452fbSAndroid Build Coastguard WorkerThe PF host API **SHOULD** be structured.
1049*c33452fbSAndroid Build Coastguard WorkerI.e.: the PF, when requested for a list of domains, should return a list of
1050*c33452fbSAndroid Build Coastguard Workerstructured object, each containing configuration objects, containing their
1051*c33452fbSAndroid Build Coastguard Workervalues...
1052*c33452fbSAndroid Build Coastguard Worker<why>The reference implementation has a string oriented API. E.g/: The list of
1053*c33452fbSAndroid Build Coastguard Workerdomains is returned as a concatenation of domains name in one big string. This
1054*c33452fbSAndroid Build Coastguard Workerleads to hard to use API from C and C++ code. Especially for testing</why>
1055*c33452fbSAndroid Build Coastguard Worker
1056*c33452fbSAndroid Build Coastguard Worker### Implementation language
1057*c33452fbSAndroid Build Coastguard WorkerThe main implementation will transition to C++11 for
1058*c33452fbSAndroid Build Coastguard Worker - cross platform support of multi-threading
1059*c33452fbSAndroid Build Coastguard Worker - remove dependency to pthread
1060*c33452fbSAndroid Build Coastguard Worker - reduce the gap with the "next" branch
1061*c33452fbSAndroid Build Coastguard WorkerIt will be compatible with android thank to clang's libc++"
1062*c33452fbSAndroid Build Coastguard Worker
1063*c33452fbSAndroid Build Coastguard Worker<note>Put this in a design document.</note>
1064*c33452fbSAndroid Build Coastguard Worker
1065*c33452fbSAndroid Build Coastguard Worker## Long term
1066*c33452fbSAndroid Build Coastguard WorkerThe following requirements are not planned to be implemented any time soon as
1067*c33452fbSAndroid Build Coastguard Workertheir is not need identified but are rather a long term guidance.
1068*c33452fbSAndroid Build Coastguard Worker
1069*c33452fbSAndroid Build Coastguard Worker### Custom parameter types
1070*c33452fbSAndroid Build Coastguard WorkerThe client **MAY** inject custom parameters types.
1071*c33452fbSAndroid Build Coastguard Worker<why>As the client creates parameters it should also be able to specify the
1072*c33452fbSAndroid Build Coastguard Workerparameter contains ie its types. Without this possibility the client has to
1073*c33452fbSAndroid Build Coastguard Workerchoose a built-in that may not match what he wants.
1074*c33452fbSAndroid Build Coastguard Worker
1075*c33452fbSAndroid Build Coastguard WorkerFor example representing a prime number with an integer would not allow to enforce primness.
1076*c33452fbSAndroid Build Coastguard Worker
1077*c33452fbSAndroid Build Coastguard WorkerFor example a complex number could be represented with two float but `a+bi` format
1078*c33452fbSAndroid Build Coastguard Workercould not be used.
1079*c33452fbSAndroid Build Coastguard Worker
1080*c33452fbSAndroid Build Coastguard WorkerFor example stocking a parameter with a dynamic type, say either a string or a number
1081*c33452fbSAndroid Build Coastguard Workercould be done with a boolean a string and a number but this could not be pretty
1082*c33452fbSAndroid Build Coastguard Workerprint and not memory efficient.
1083*c33452fbSAndroid Build Coastguard Worker</why>
1084*c33452fbSAndroid Build Coastguard Worker
1085*c33452fbSAndroid Build Coastguard Worker### Structure tunning
1086*c33452fbSAndroid Build Coastguard WorkerUsers **MAY** be able to modify the parameters (types, identifiers, tree...) with
1087*c33452fbSAndroid Build Coastguard Workerminimal effort (in the same way they can modify the inference engine).
1088*c33452fbSAndroid Build Coastguard Worker<ko>The reference implementation does not support it.</ko>
1089*c33452fbSAndroid Build Coastguard Worker<why>To enable a fast modify-update-test cycle on PF configuration.</why>
1090*c33452fbSAndroid Build Coastguard Worker
1091*c33452fbSAndroid Build Coastguard Worker### Immutable parameters
1092*c33452fbSAndroid Build Coastguard WorkerA PF **MAY** support immutable parameters, i.e. parameters which value is determined
1093*c33452fbSAndroid Build Coastguard Workeron start then read only.
1094*c33452fbSAndroid Build Coastguard Worker<why>To permit hardware read only value reflection.</why>
1095*c33452fbSAndroid Build Coastguard Worker<ko>This is not implemented in the PF reference implementation.</ko>
1096*c33452fbSAndroid Build Coastguard Worker
1097*c33452fbSAndroid Build Coastguard WorkerThis value **MUST** be gettable for an immutable parameter.
1098*c33452fbSAndroid Build Coastguard Worker<why>A parameter that can not be accessed (read or write) is of no use.</why>
1099*c33452fbSAndroid Build Coastguard Worker
1100*c33452fbSAndroid Build Coastguard Worker### Endianess adaptation
1101*c33452fbSAndroid Build Coastguard WorkerA parameter or a block of parameters might be presented by the Parameter
1102*c33452fbSAndroid Build Coastguard WorkerFramework but only used as a passthrough to the underlying subsystem (think
1103*c33452fbSAndroid Build Coastguard Worker"`(void *)` interfaces"). It is then possible that the endianess of the
1104*c33452fbSAndroid Build Coastguard Workersubsystem differs from the one the Parameter Framework is running on, an
1105*c33452fbSAndroid Build Coastguard Workerendianness adaptation would allow supporting those cases.
1106*c33452fbSAndroid Build Coastguard Worker
1107*c33452fbSAndroid Build Coastguard WorkerThis can be seen as related to the "Parameter Adaptation" requirement or even
1108*c33452fbSAndroid Build Coastguard Workeras a special case.
1109*c33452fbSAndroid Build Coastguard Worker
1110*c33452fbSAndroid Build Coastguard Worker</article>
1111