2010-06-14 14:27:40 +00:00
|
|
|
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
|
|
|
|
|
|
|
|
// Dummy brick (just for demonstration)
|
|
|
|
|
2010-07-30 05:46:22 +00:00
|
|
|
//#define BRICK_DEBUGGING
|
|
|
|
//#define MARS_DEBUGGING
|
|
|
|
|
2010-06-14 14:27:40 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#include "mars.h"
|
|
|
|
|
|
|
|
///////////////////////// own type definitions ////////////////////////
|
|
|
|
|
2010-06-20 18:55:34 +00:00
|
|
|
#include "mars_dummy.h"
|
2010-06-14 14:27:40 +00:00
|
|
|
|
2010-07-07 14:09:16 +00:00
|
|
|
///////////////////////// own helper functions ////////////////////////
|
|
|
|
|
2010-06-14 14:27:40 +00:00
|
|
|
////////////////// own brick / input / output operations //////////////////
|
|
|
|
|
2010-07-07 14:09:16 +00:00
|
|
|
static int dummy_get_info(struct dummy_output *output, struct mars_info *info)
|
2010-06-28 05:53:46 +00:00
|
|
|
{
|
|
|
|
struct dummy_input *input = output->brick->inputs[0];
|
2010-07-07 14:09:16 +00:00
|
|
|
return GENERIC_INPUT_CALL(input, mars_get_info, info);
|
2010-07-05 15:56:58 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 12:13:18 +00:00
|
|
|
static int dummy_ref_get(struct dummy_output *output, struct mref_object *mref)
|
2010-07-05 15:56:58 +00:00
|
|
|
{
|
|
|
|
struct dummy_input *input = output->brick->inputs[0];
|
2010-12-15 12:13:18 +00:00
|
|
|
return GENERIC_INPUT_CALL(input, mref_get, mref);
|
2010-07-05 15:56:58 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 12:13:18 +00:00
|
|
|
static void dummy_ref_put(struct dummy_output *output, struct mref_object *mref)
|
2010-07-05 15:56:58 +00:00
|
|
|
{
|
|
|
|
struct dummy_input *input = output->brick->inputs[0];
|
2010-12-15 12:13:18 +00:00
|
|
|
GENERIC_INPUT_CALL(input, mref_put, mref);
|
2010-07-05 15:56:58 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 12:13:18 +00:00
|
|
|
static void dummy_ref_io(struct dummy_output *output, struct mref_object *mref)
|
2010-07-05 15:56:58 +00:00
|
|
|
{
|
|
|
|
struct dummy_input *input = output->brick->inputs[0];
|
2010-12-15 12:13:18 +00:00
|
|
|
GENERIC_INPUT_CALL(input, mref_io, mref);
|
2010-06-28 05:53:46 +00:00
|
|
|
}
|
|
|
|
|
2011-02-23 20:48:06 +00:00
|
|
|
static int dummy_switch(struct dummy_brick *brick)
|
|
|
|
{
|
|
|
|
if (brick->power.button) {
|
|
|
|
mars_power_led_off((void*)brick, false);
|
|
|
|
//...
|
|
|
|
mars_power_led_on((void*)brick, true);
|
|
|
|
} else {
|
|
|
|
mars_power_led_on((void*)brick, false);
|
|
|
|
//...
|
|
|
|
mars_power_led_off((void*)brick, true);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-22 13:21:42 +00:00
|
|
|
//////////////// object / aspect constructors / destructors ///////////////
|
|
|
|
|
2010-12-15 12:13:18 +00:00
|
|
|
static int dummy_mref_aspect_init_fn(struct generic_aspect *_ini, void *_init_data)
|
2010-07-05 15:56:58 +00:00
|
|
|
{
|
2010-12-15 12:13:18 +00:00
|
|
|
struct dummy_mref_aspect *ini = (void*)_ini;
|
2010-08-08 09:03:42 +00:00
|
|
|
(void)ini;
|
2011-02-23 20:48:06 +00:00
|
|
|
//ini->my_own = 0;
|
2010-07-05 15:56:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-15 12:13:18 +00:00
|
|
|
static void dummy_mref_aspect_exit_fn(struct generic_aspect *_ini, void *_init_data)
|
2010-08-08 09:03:42 +00:00
|
|
|
{
|
2010-12-15 12:13:18 +00:00
|
|
|
struct dummy_mref_aspect *ini = (void*)_ini;
|
2010-08-08 09:03:42 +00:00
|
|
|
(void)ini;
|
|
|
|
}
|
|
|
|
|
2010-07-23 11:55:18 +00:00
|
|
|
MARS_MAKE_STATICS(dummy);
|
|
|
|
|
2010-06-22 13:21:42 +00:00
|
|
|
////////////////////// brick constructors / destructors ////////////////////
|
2010-06-14 14:27:40 +00:00
|
|
|
|
|
|
|
static int dummy_brick_construct(struct dummy_brick *brick)
|
|
|
|
{
|
2011-02-23 20:48:06 +00:00
|
|
|
//brick->my_own = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dummy_brick_destruct(struct dummy_brick *brick)
|
|
|
|
{
|
2010-06-14 14:27:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dummy_output_construct(struct dummy_output *output)
|
|
|
|
{
|
2011-02-23 20:48:06 +00:00
|
|
|
//output->my_own = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dummy_output_destruct(struct dummy_output *output)
|
|
|
|
{
|
2010-06-14 14:27:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////// static structs ////////////////////////
|
|
|
|
|
|
|
|
static struct dummy_brick_ops dummy_brick_ops = {
|
2011-02-23 20:48:06 +00:00
|
|
|
.brick_switch = dummy_switch,
|
2010-06-14 14:27:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct dummy_output_ops dummy_output_ops = {
|
2010-06-22 13:21:42 +00:00
|
|
|
.make_object_layout = dummy_make_object_layout,
|
2010-07-07 14:09:16 +00:00
|
|
|
.mars_get_info = dummy_get_info,
|
2010-12-15 12:13:18 +00:00
|
|
|
.mref_get = dummy_ref_get,
|
|
|
|
.mref_put = dummy_ref_put,
|
|
|
|
.mref_io = dummy_ref_io,
|
2010-06-14 14:27:40 +00:00
|
|
|
};
|
|
|
|
|
2010-08-10 17:39:30 +00:00
|
|
|
const struct dummy_input_type dummy_input_type = {
|
2010-06-14 14:27:40 +00:00
|
|
|
.type_name = "dummy_input",
|
|
|
|
.input_size = sizeof(struct dummy_input),
|
|
|
|
};
|
|
|
|
|
2010-07-23 11:55:18 +00:00
|
|
|
static const struct dummy_input_type *dummy_input_types[] = {
|
2010-06-14 14:27:40 +00:00
|
|
|
&dummy_input_type,
|
|
|
|
};
|
|
|
|
|
2010-08-10 17:39:30 +00:00
|
|
|
const struct dummy_output_type dummy_output_type = {
|
2010-06-14 14:27:40 +00:00
|
|
|
.type_name = "dummy_output",
|
|
|
|
.output_size = sizeof(struct dummy_output),
|
|
|
|
.master_ops = &dummy_output_ops,
|
|
|
|
.output_construct = &dummy_output_construct,
|
2011-02-23 20:48:06 +00:00
|
|
|
.output_destruct = &dummy_output_destruct,
|
2010-07-30 05:46:22 +00:00
|
|
|
.aspect_types = dummy_aspect_types,
|
|
|
|
.layout_code = {
|
2010-12-15 12:13:18 +00:00
|
|
|
[BRICK_OBJ_MREF] = LAYOUT_ALL,
|
2010-07-23 11:55:18 +00:00
|
|
|
}
|
2010-06-14 14:27:40 +00:00
|
|
|
};
|
|
|
|
|
2010-07-23 11:55:18 +00:00
|
|
|
static const struct dummy_output_type *dummy_output_types[] = {
|
2010-06-14 14:27:40 +00:00
|
|
|
&dummy_output_type,
|
|
|
|
};
|
|
|
|
|
2010-07-23 11:55:18 +00:00
|
|
|
const struct dummy_brick_type dummy_brick_type = {
|
2010-06-14 14:27:40 +00:00
|
|
|
.type_name = "dummy_brick",
|
|
|
|
.brick_size = sizeof(struct dummy_brick),
|
|
|
|
.max_inputs = 1,
|
|
|
|
.max_outputs = 1,
|
|
|
|
.master_ops = &dummy_brick_ops,
|
|
|
|
.default_input_types = dummy_input_types,
|
|
|
|
.default_output_types = dummy_output_types,
|
|
|
|
.brick_construct = &dummy_brick_construct,
|
2011-02-23 20:48:06 +00:00
|
|
|
.brick_destruct = &dummy_brick_destruct,
|
2010-06-14 14:27:40 +00:00
|
|
|
};
|
|
|
|
EXPORT_SYMBOL_GPL(dummy_brick_type);
|
|
|
|
|
|
|
|
////////////////// module init stuff /////////////////////////
|
|
|
|
|
|
|
|
static int __init init_dummy(void)
|
|
|
|
{
|
2011-02-23 20:48:06 +00:00
|
|
|
MARS_INF("init_dummy()\n");
|
2010-06-14 14:27:40 +00:00
|
|
|
return dummy_register_brick_type();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_dummy(void)
|
|
|
|
{
|
2011-02-23 20:48:06 +00:00
|
|
|
MARS_INF("exit_dummy()\n");
|
2010-06-14 14:27:40 +00:00
|
|
|
dummy_unregister_brick_type();
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("MARS dummy brick");
|
|
|
|
MODULE_AUTHOR("Thomas Schoebel-Theuer <tst@1und1.de>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(init_dummy);
|
|
|
|
module_exit(exit_dummy);
|