With this patch we can set the calibration data in: /sys/class/i2c-adapter/i2c-0/0-0073/s3c2440-ts/calibration/[0-6]
We can do it in two ways: 1) send "struct platform_device *pdev" to the filters so that they can register sysfs objects. 2) modify the TS driver to add calibration logic, not using the same API the filters use but a different one for calibration. I did prefer the first alternative. Is it OK to trust pdev to the filters? We could also share pdev's kobject only. Signed-off-by: Nelson Castillo <[email protected]> --- drivers/input/touchscreen/s3c2410_ts.c | 6 +++--- drivers/input/touchscreen/ts_filter.c | 12 +++++++----- drivers/input/touchscreen/ts_filter_group.c | 6 ++++-- drivers/input/touchscreen/ts_filter_linear.c | 11 ++++++----- drivers/input/touchscreen/ts_filter_mean.c | 6 ++++-- drivers/input/touchscreen/ts_filter_median.c | 6 ++++-- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c index 4159ada..bc9b410 100644 --- a/drivers/input/touchscreen/s3c2410_ts.c +++ b/drivers/input/touchscreen/s3c2410_ts.c @@ -435,7 +435,7 @@ static int __init s3c2410ts_probe(struct platform_device *pdev) /* create the filter chain set up for the 2 coordinates we produce */ ret = ts_filter_create_chain( - (struct ts_filter_api **)&info->filter_sequence, + pdev, (struct ts_filter_api **)&info->filter_sequence, (void *)&info->filter_config, ts.tsf, ARRAY_SIZE(ts.coords)); if (ret) dev_info(&pdev->dev, "%d filter(s) initialized\n", ret); @@ -484,7 +484,7 @@ bail5: bail4: disable_irq(IRQ_ADC); bail3: - ts_filter_destroy_chain(ts.tsf); + ts_filter_destroy_chain(pdev, ts.tsf); kfifo_free(ts.event_fifo); bail2: input_unregister_device(ts.dev); @@ -511,7 +511,7 @@ static int s3c2410ts_remove(struct platform_device *pdev) input_unregister_device(ts.dev); iounmap(base_addr); - ts_filter_destroy_chain(ts.tsf); + ts_filter_destroy_chain(pdev, ts.tsf); kfifo_free(ts.event_fifo); diff --git a/drivers/input/touchscreen/ts_filter.c b/drivers/input/touchscreen/ts_filter.c index e141bd8..1508388 100644 --- a/drivers/input/touchscreen/ts_filter.c +++ b/drivers/input/touchscreen/ts_filter.c @@ -20,8 +20,9 @@ #include <linux/device.h> #include <linux/ts_filter.h> -int ts_filter_create_chain(struct ts_filter_api **api, void **config, - struct ts_filter **list, int count_coords) +int ts_filter_create_chain(struct platform_device *pdev, + struct ts_filter_api **api, void **config, + struct ts_filter **list, int count_coords) { int count = 0; struct ts_filter *last = NULL; @@ -30,7 +31,7 @@ int ts_filter_create_chain(struct ts_filter_api **api, void **config, return 0; while (*api && count < MAX_TS_FILTER_CHAIN) { - *list = ((*api)->create)(*config++, count_coords); + *list = ((*api)->create)(pdev, *config++, count_coords); if (!*list) { printk(KERN_ERR "Filter %d failed init\n", count); return count; @@ -47,14 +48,15 @@ int ts_filter_create_chain(struct ts_filter_api **api, void **config, } EXPORT_SYMBOL_GPL(ts_filter_create_chain); -void ts_filter_destroy_chain(struct ts_filter **list) +void ts_filter_destroy_chain(struct platform_device *pdev, + struct ts_filter **list) { struct ts_filter **first; int count = 0; first = list; while (*list && count++ < MAX_TS_FILTER_CHAIN) { - ((*list)->api->destroy)(*list); + ((*list)->api->destroy)(pdev, *list); list++; } *first = NULL; diff --git a/drivers/input/touchscreen/ts_filter_group.c b/drivers/input/touchscreen/ts_filter_group.c index 250613f..80e6677 100644 --- a/drivers/input/touchscreen/ts_filter_group.c +++ b/drivers/input/touchscreen/ts_filter_group.c @@ -59,7 +59,8 @@ static void ts_filter_group_clear(struct ts_filter *tsf) (tsf->next->api->clear)(tsf->next); } -static struct ts_filter *ts_filter_group_create(void *conf, int count_coords) +static struct ts_filter *ts_filter_group_create(struct platform_device *pdev, + void *conf, int count_coords) { struct ts_filter_group *tsfg; int i; @@ -97,7 +98,8 @@ static struct ts_filter *ts_filter_group_create(void *conf, int count_coords) return &tsfg->tsf; } -static void ts_filter_group_destroy(struct ts_filter *tsf) +static void ts_filter_group_destroy(struct platform_device *pdev, + struct ts_filter *tsf) { struct ts_filter_group *tsfg = (struct ts_filter_group *)tsf; diff --git a/drivers/input/touchscreen/ts_filter_linear.c b/drivers/input/touchscreen/ts_filter_linear.c index 01b66a1..4803e17 100644 --- a/drivers/input/touchscreen/ts_filter_linear.c +++ b/drivers/input/touchscreen/ts_filter_linear.c @@ -86,7 +86,8 @@ static ssize_t const_store(struct const_obj *obj, struct const_attribute *attr, * filter functions */ -static struct ts_filter *ts_filter_linear_create(void *conf, int count_coords) +static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev, + void *conf, int count_coords) { struct ts_filter_linear *tsfl; int i; @@ -118,8 +119,8 @@ static struct ts_filter *ts_filter_linear_create(void *conf, int count_coords) tsfl->c_obj.tsfl = tsfl; /* kernel frees tsfl in const_release */ /* TODO: /sys/ts-calibration is not OK */ - ret = kobject_init_and_add(&tsfl->c_obj.kobj, &tsfl->const_ktype, NULL, - "ts-calibration"); + ret = kobject_init_and_add(&tsfl->c_obj.kobj, &tsfl->const_ktype, + &pdev->dev.kobj, "calibration"); if (ret) { kobject_put(&tsfl->c_obj.kobj); return NULL; @@ -130,8 +131,8 @@ static struct ts_filter *ts_filter_linear_create(void *conf, int count_coords) return &tsfl->tsf; } - -static void ts_filter_linear_destroy(struct ts_filter *tsf) +static void ts_filter_linear_destroy(struct platform_device *pdev, + struct ts_filter *tsf) { struct ts_filter_linear *tsfl = (struct ts_filter_linear *)tsf; diff --git a/drivers/input/touchscreen/ts_filter_mean.c b/drivers/input/touchscreen/ts_filter_mean.c index a2f1748..a7b4a5a 100644 --- a/drivers/input/touchscreen/ts_filter_mean.c +++ b/drivers/input/touchscreen/ts_filter_mean.c @@ -56,7 +56,8 @@ static void ts_filter_mean_clear(struct ts_filter *tsf) (tsf->next->api->clear)(tsf->next); } -static struct ts_filter *ts_filter_mean_create(void *config, int count_coords) +static struct ts_filter *ts_filter_mean_create(struct platform_device *pdev, + void *config, int count_coords) { int *p; int n; @@ -96,7 +97,8 @@ static struct ts_filter *ts_filter_mean_create(void *config, int count_coords) return &tsfs->tsf; } -static void ts_filter_mean_destroy(struct ts_filter *tsf) +static void ts_filter_mean_destroy(struct platform_device *pdev, + struct ts_filter *tsf) { struct ts_filter_mean *tsfs = (struct ts_filter_mean *)tsf; diff --git a/drivers/input/touchscreen/ts_filter_median.c b/drivers/input/touchscreen/ts_filter_median.c index 67dd3fe..883ab06 100644 --- a/drivers/input/touchscreen/ts_filter_median.c +++ b/drivers/input/touchscreen/ts_filter_median.c @@ -81,7 +81,8 @@ static void ts_filter_median_clear(struct ts_filter *tsf) (tsf->next->api->clear)(tsf->next); } -static struct ts_filter *ts_filter_median_create(void * conf, int count_coords) +static struct ts_filter *ts_filter_median_create(struct platform_device *pdev, + void *conf, int count_coords) { int *p; int n; @@ -120,7 +121,8 @@ static struct ts_filter *ts_filter_median_create(void * conf, int count_coords) return &tsfm->tsf; } -static void ts_filter_median_destroy(struct ts_filter *tsf) +static void ts_filter_median_destroy(struct platform_device *pdev, + struct ts_filter *tsf) { struct ts_filter_median *tsfm = (struct ts_filter_median *)tsf; diff --git a/include/linux/ts_filter.h b/include/linux/ts_filter.h index 715f1ba..1671044 100644 --- a/include/linux/ts_filter.h +++ b/include/linux/ts_filter.h @@ -7,6 +7,8 @@ * (c) 2008 Andy Green <[email protected]> */ +#include <linux/platform_device.h> + #define MAX_TS_FILTER_CHAIN 4 /* max filters you can chain up */ #define MAX_TS_FILTER_COORDS 3 /* X, Y and Z (pressure) */ @@ -15,8 +17,9 @@ struct ts_filter; /* operations that a filter can perform */ struct ts_filter_api { - struct ts_filter * (*create)(void *config, int count_coords); - void (*destroy)(struct ts_filter *filter); + struct ts_filter * (*create)(struct platform_device *pdev, void *config, + int count_coords); + void (*destroy)(struct platform_device *pdev, struct ts_filter *filter); void (*clear)(struct ts_filter *filter); int (*process)(struct ts_filter *filter, int *coords); void (*scale)(struct ts_filter *filter, int *coords); @@ -41,10 +44,13 @@ struct ts_filter { * array and fills in ->next pointers to create the chain */ -extern int ts_filter_create_chain(struct ts_filter_api **api, void **config, - struct ts_filter **list, int count_coords); +extern int ts_filter_create_chain(struct platform_device *pdev, + struct ts_filter_api **api, void **config, + struct ts_filter **list, int count_coords); /* helper to destroy a whole chain from the list of filter pointers */ -extern void ts_filter_destroy_chain(struct ts_filter **list); +extern void ts_filter_destroy_chain(struct platform_device *pdev, + struct ts_filter **list); + #endif
