On Jul 21, 10:01 pm, rui kou <[email protected]> wrote:
> I am trying to make ipaq h3900 asc2 touchscreen  work, and I have read
> many discuss, but it not work.
>
> static void report_touchpanel (struct touchscreen_data *ts, int x, int y,
> int pressure)
> {
> int xtmp, ytmp;
> int axis_table[] = {25012, -231, -2094140, 383, 18073, 144000, 16}; // from
> /etc/pointercal by ts_calibrate
>         #if 0
> input_report_abs(ts->input, ABS_X, x);
> input_report_abs(ts->input, ABS_Y, y);
>  #endif
>  //-----------------> android tslib
>  xtmp = (axis_table[2] + axis_table[0]*x + axis_table[1]*y )>> axis_table[6];
>
>         ytmp = (axis_table[5] + axis_table[3]*x + axis_table[4]*y )>> 
> axis_table[6];
>
> input_report_abs(ts->input, ABS_X, xtmp);
>  input_report_abs(ts->input, ABS_Y, ytmp);
>  input_report_abs(ts->input, ABS_PRESSURE, pressure);
>  input_report_key(ts->input, BTN_TOUCH, 0);
> input_sync(ts->input);
>
> }

Try changing the above code by adding some additional logic for the
reporting of the key BTN_TOUCH value such as below:

if (pressure > MIN_TOUCH_PRESSURE) {
        input_report_abs(ts->input, ABS_X, xtmp);
        input_report_abs(ts->input, ABS_Y, ytmp);
        input_report_abs(ts->input, ABS_PRESSURE, pressure);
        input_report_key(ts->input, BTN_TOUCH, 1);
        input_sync(ts->input);
} else {
        input_report_abs(ts->input, ABS_PRESSURE, 0);
        input_report_key(ts->input, BTN_TOUCH, 0);
        input_sync(ts->input);
}




> int asic2_touchscreen_attach (struct adc_data *adc)
> {
> int result;
> struct touchscreen_data *ts;
>
> ts = kmalloc (sizeof (*ts), GFP_KERNEL);
>  if (!ts)
> return -ENOMEM;
> memset (ts, 0, sizeof (*ts));
>  ts->input = input_allocate_device();
>
> init_timer (&ts->timer);
>  ts->timer.function = asic2_timer_callback;
> ts->timer.data     = (unsigned long)adc;
>  ts->state          = TS_STATE_WAIT_PEN_DOWN;
> ts->pen_irq        = asic2_irq_base (adc->asic) + IRQ_IPAQ_ASIC2_PEN;
>
> set_bit(EV_ABS, ts->input->evbit);

Here is the major problem. All of the key input events are
automatically filtered out by the input framework in the kernel and
they never reach user space (i.e., the Android stack) because the
event bit for keys is not set.
Add this line to indicate you will be reporting key events in your
driver:
set_bit(EV_KEY, ts->input->evbit);

I know it sounds odd that you have to report key events for a
touchscreen driver, but that is what the user space Android code is
triggering off of as it is looking for touch events.

> ts->input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
>
> ts->input->absmin[ABS_X] = 0;   ts->input->absmin[ABS_Y] = 0;
> ts->input->absmin[ABS_PRESSURE] = 0;
> ts->input->absmax[ABS_X] = 1023; ts->input->absmax[ABS_Y] = 1023;
> ts->input->absmax[ABS_PRESSURE] = 1;

The code above does not hurt anything, but it is redundant given the
code below does the say thing.

> input_set_abs_params(ts->input, ABS_X, 0, 1023, 0, 0);
> input_set_abs_params(ts->input, ABS_Y, 0, 1023, 0, 0);
>  input_set_abs_params(ts->input, ABS_PRESSURE, 0, 1, 0, 0);
>   ts->input->name = "asic2 ts";
> // ts->input->private = ts;
>  ts->input->phys = "asic2 ts\0";
> ts->input->id.bustype = BUS_HOST;
>
> ts->input->open = asic2_ts_open;
> ts->input->close = asic2_ts_close;
>
> input_register_device(ts->input);
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to