summaryrefslogtreecommitdiffstats
path: root/plugins/lua2c-interface.c
blob: d57cfbd65bc56ac655191b8699b251c4d8241fa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (C) 2016 "IoT.bzh"
 * Author Romain Forlot <romain.forlot@iot.bzh>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

#define _GNU_SOURCE  // needed for vasprintf

#define AFB_BINDING_VERSION 2
#include <afb/afb-binding.h>
#include <systemd/sd-event.h>
#include <json-c/json_object.h>
#include <stdbool.h>
#include <string.h>

#include "ctl-config.h"
#include "wrap-json.h"

CTLP_LUALOAD
CTLP_REGISTER("lua2c-interface");

typedef struct {
	struct pluginCBT* pluginHandle;
} lowCANCtxT;

// Call at initialisation time
CTLP_ONLOAD(plugin, handle) {
	lowCANCtxT *pluginCtx= (lowCANCtxT*)calloc (1, sizeof(lowCANCtxT));
	pluginCtx->pluginHandle = (struct pluginCBT*)handle;

	AFB_NOTICE ("Low-can plugin: label='%s' version='%s' info='%s'",
		plugin->label,
		plugin->version,
		plugin->info);

	return (void*)pluginCtx;
}
/*
CTLP_LUA2C (LUAsetSignalValue, label, argsJ, context)
{
	AFB_NOTICE("label: %s, argsJ: %s", label, json_object_to_json_string(argsJ));
	return 0;
}
*/
highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
state.ak4613 {
	control.1 {
		iface MIXER
		name 'Digital Playback Volume1'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.2 {
		iface MIXER
		name 'Digital Playback Volume2'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.3 {
		iface MIXER
		name 'Digital Playback Volume3'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.4 {
		iface MIXER
		name 'Digital Playback Volume4'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.5 {
		iface MIXER
		name 'Digital Playback Volume5'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.6 {
		iface MIXER
		name 'Digital Playback Volume6'
		value.0 204
		value.1 204
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 255'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -2550
			dbvalue.1 -2550
		}
	}
	control.7 {
		iface MIXER
		name 'DVC Out Playback Volume'
		value.0 1677647
		value.1 1677647
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 8388607'
		}
	}
	control.8 {
		iface MIXER
		name 'DVC Out Mute Switch'
		value.0 false
		value.1 false
		comment {
			access 'read write'
			type BOOLEAN
			count 2
		}
	}
	control.9 {
		iface MIXER
		name 'DVC Out Ramp Switch'
		value false
		comment {
			access 'read write'
			type BOOLEAN
			count 1
		}
	}
	control.10 {
		iface MIXER
		name 'DVC Out Ramp Up Rate'
		value '128 dB/1 step'
		comment {
			access 'read write'
			type ENUMERATED
			count 1
			item.0 '128 dB/1 step'
			item.1 '64 dB/1 step'
			item.2 '32 dB/1 step'
			item.3 '16 dB/1 step'
			item.4 '8 dB/1 step'
			item.5 '4 dB/1 step'
			item.6 '2 dB/1 step'
			item.7 '1 dB/1 step'
			item.8 '0.5 dB/1 step'
			item.9 '0.25 dB/1 step'
			item.10 '0.125 dB/1 step'
			item.11 '0.125 dB/2 steps'
			item.12 '0.125 dB/4 steps'
			item.13 '0.125 dB/8 steps'
			item.14 '0.125 dB/16 steps'
			item.15 '0.125 dB/32 steps'
			item.16 '0.125 dB/64 steps'
			item.17 '0.125 dB/128 steps'
			item.18 '0.125 dB/256 steps'
			item.19 '0.125 dB/512 steps'
			item.20 '0.125 dB/1024 steps'
			item.21 '0.125 dB/2048 steps'
			item.22 '0.125 dB/4096 steps'
			item.23 '0.125 dB/8192 steps'
		}
	}
	control.11 {
		iface MIXER
		name 'DVC Out Ramp Down Rate'
		value '128 dB/1 step'
		comment {
			access 'read write'
			type ENUMERATED
			count 1
			item.0 '128 dB/1 step'
			item.1 '64 dB/1 step'
			item.2 '32 dB/1 step'
			item.3 '16 dB/1 step'
			item.4 '8 dB/1 step'
			item.5 '4 dB/1 step'
			item.6 '2 dB/1 step'
			item.7 '1 dB/1 step'
			item.8 '0.5 dB/1 step'
			item.9 '0.25 dB/1 step'
			item.10 '0.125 dB/1 step'
			item.11 '0.125 dB/2 steps'
			item.12 '0.125 dB/4 steps'
			item.13 '0.125 dB/8 steps'
			item.14 '0.125 dB/16 steps'
			item.15 '0.125 dB/32 steps'
			item.16 '0.125 dB/64 steps'
			item.17 '0.125 dB/128 steps'
			item.18 '0.125 dB/256 steps'
			item.19 '0.125 dB/512 steps'
			item.20 '0.125 dB/1024 steps'
			item.21 '0.125 dB/2048 steps'
			item.22 '0.125 dB/4096 steps'
			item.23 '0.125 dB/8192 steps'
		}
	}
	control.12 {
		iface MIXER
		name 'SRC Out Rate Switch'
		value false
		comment {
			access 'read write'
			type BOOLEAN
			count 1
		}
	}
	control.13 {
		iface MIXER
		name 'SRC Out Rate'
		value 0
		comment {
			access 'read write'
			type INTEGER
			count 1
			range '0 - 192000'
		}
	}
	control.14 {
		iface MIXER
		name 'DVC In Capture Volume'
		value.0 838870
		value.1 838870
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 8388607'
		}
	}
	control.15 {
		iface MIXER
		name 'DVC In Mute Switch'
		value.0 false
		value.1 false
		comment {
			access 'read write'
			type BOOLEAN
			count 2
		}
	}
	control.16 {
		iface MIXER
		name 'DVC In Ramp Switch'
		value false
		comment {
			access 'read write'
			type BOOLEAN
			count 1
		}
	}
	control.17 {
		iface MIXER
		name 'DVC In Ramp Up Rate'
		value '128 dB/1 step'
		comment {
			access 'read write'
			type ENUMERATED
			count 1
			item.0 '128 dB/1 step'
			item.1 '64 dB/1 step'
			item.2 '32 dB/1 step'
			item.3 '16 dB/1 step'
			item.4 '8 dB/1 step'
			item.5 '4 dB/1 step'
			item.6 '2 dB/1 step'
			item.7 '1 dB/1 step'
			item.8 '0.5 dB/1 step'
			item.9 '0.25 dB/1 step'
			item.10 '0.125 dB/1 step'
			item.11 '0.125 dB/2 steps'
			item.12 '0.125 dB/4 steps'
			item.13 '0.125 dB/8 steps'
			item.14 '0.125 dB/16 steps'
			item.15 '0.125 dB/32 steps'
			item.16 '0.125 dB/64 steps'
			item.17 '0.125 dB/128 steps'
			item.18 '0.125 dB/256 steps'
			item.19 '0.125 dB/512 steps'
			item.20 '0.125 dB/1024 steps'
			item.21 '0.125 dB/2048 steps'
			item.22 '0.125 dB/4096 steps'
			item.23 '0.125 dB/8192 steps'
		}
	}
	control.18 {
		iface MIXER
		name 'DVC In Ramp Down Rate'
		value '128 dB/1 step'
		comment {
			access 'read write'
			type ENUMERATED
			count 1
			item.0 '128 dB/1 step'
			item.1 '64 dB/1 step'
			item.2 '32 dB/1 step'
			item.3 '16 dB/1 step'
			item.4 '8 dB/1 step'
			item.5 '4 dB/1 step'
			item.6 '2 dB/1 step'
			item.7 '1 dB/1 step'
			item.8 '0.5 dB/1 step'
			item.9 '0.25 dB/1 step'
			item.10 '0.125 dB/1 step'
			item.11 '0.125 dB/2 steps'
			item.12 '0.125 dB/4 steps'
			item.13 '0.125 dB/8 steps'
			item.14 '0.125 dB/16 steps'
			item.15 '0.125 dB/32 steps'
			item.16 '0.125 dB/64 steps'
			item.17 '0.125 dB/128 steps'
			item.18 '0.125 dB/256 steps'
			item.19 '0.125 dB/512 steps'
			item.20 '0.125 dB/1024 steps'
			item.21 '0.125 dB/2048 steps'
			item.22 '0.125 dB/4096 steps'
			item.23 '0.125 dB/8192 steps'
		}
	}
}