u16 cal_range_y;
unsigned int stav;
u8 auto_calibration;
+ u8 is_open;
};
-
-struct mx1ts mx1_ts;
-
static inline void mx1ts_reg_set_mask(struct mx1ts *mts , unsigned int reg, u32 mask)
{
u32 val;
input_report_abs(idev, ABS_X, x);
input_report_abs(idev, ABS_Y, y);
/* input_report_abs(idev, ABS_PRESSURE, pressure);*/
- printk(KERN_ERR "P %i X %i Y %i.\n", p, x, y);
+ /*printk(KERN_ERR "P %i X %i Y %i.\n", p, x, y);*/ /*devprint dev_dbg(zarizeni, co se vypisuje)*/
input_sync(idev);
}
* in the FIFO.
*/
/*static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id)*/
-static irqreturn_t mx1ts_pendata_irq(int irq, struct mx1ts *mts)
+static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id)
{
+ struct mx1ts *mts = (struct mx1ts *)dev_id;
u16 mx1_cal_range_x;
u16 mx1_cal_range_y;
static unsigned int auto_zero, pen_x, pen_y, pen_u;
mx1ts_disable_pen_up_interrupt(mts);
mx1ts_enable_pen_touch_interrupt(mts);
- mx1ts_evt_add(mts, 0, 0, 0);
+ if(mts->is_open)
+ mx1ts_evt_add(mts->ts_idev, 0, 0, 0);
printk(KERN_ERR "Zaplnena fifo.\n");
mx1ts_flush_fifo(mts);
pen_y = (u32)(((pen_y - auto_zero) << 16) /
mts->cal_range_y);
- mx1ts_evt_add(mts, 1, pen_x, pen_y);
+ if(mts->is_open)
+ mx1ts_evt_add(mts->ts_idev, 1, pen_x, pen_y);
}
return IRQ_HANDLED;
}
return 0;
}
-static int mx1ts_close(struct platform_device *dev)
+static void mx1ts_close(struct input_dev *idev)
{
- return 0;
+ struct mx1ts *mts = dev_get_drvdata(idev->dev.parent);
+ mts->is_open = 0;
}
-static int mx1ts_open(struct platform_device *dev)
+static int mx1ts_open(struct input_dev *idev)
{
+ struct mx1ts *mts = dev_get_drvdata(idev->dev.parent);
+ mts->is_open = 1;
return 0;
}
static int mx1ts_probe(struct platform_device *dev)
{
-
- //struct mx1ts *mts= &mx1_ts;
- struct mx1ts *mts;
+ struct mx1ts *mts;
struct input_dev *idev;
int error, id, x_res, y_res;
// mx1ts_enable_pen_up_interrupt();
mts = kzalloc(sizeof(struct mx1ts), GFP_KERNEL); //alokuje pamet
- idev = input_allocate_device();
+ idev = input_allocate_device();
if (!mts || !idev) {
error = -ENOMEM;
goto err_free_devs;
return error; //XXX
}
- mx1_ts = *mts;
-
mx1ts_on(mts);
-
- return 0;
mts->ts_idev = idev;
//ucb->adcsync = adcsync;
}
printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq);*/
-// input_set_drvdata(idev, mx1_ts);
+ //input_set_drvdata(idev, mts);
+ platform_set_drvdata(dev, mts);
idev->dev.parent = &dev->dev;
idev->name = "MX1 touchscreen interface";
//idev->bustype = BUS_HOST;
- printk("<1> mx1ts: setting idev struct \tOK\t");
+ printk("<1> mx1ts: setting idev struct \tOK\n");
-/* mx1ts_adc_enable(ucb);
- x_res = mx1ts_read_xres(ucb);
- y_res = mx1ts_read_yres(ucb);
- mx1ts_adc_disable(ucb);
- printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res);*/
+ x_res = 35000;
+ y_res = 35000;
+ printk(KERN_DEBUG "mx1ts: x/y = %d/%d\n", x_res, y_res);
input_set_abs_params(idev, ABS_X, 0, x_res, 0, 0);
input_set_abs_params(idev, ABS_Y, 0, y_res, 0, 0);
input_set_abs_params(idev, ABS_PRESSURE, 0, 0, 0, 0);
-// error = input_register_device(idev);
-// if (error)
-// goto err_free_irq;
+ error = input_register_device(idev);
+ if (error)
+ goto err_free_irq;
+
+ printk("<1> mx1ts: input device registered \tOK\n");
-// dev_set_drvdata(dev, ucb);
return 0;
-// err_free_irq:
+ err_free_irq:
// free_irq(ucb->irq, ucb);
err_free_devs:
printk("<1> mx1ts: chyba pri nastavovani irq \n");
static int mx1ts_remove(struct platform_device *dev)
{
- struct mx1_ts *mts = &mx1_ts;
-
- release_mem_region(ASP_BASE_ADDR, 0x40);
- iounmap(mx1_ts.mx1ts_mem);
+ struct mx1ts *mts = platform_get_drvdata(dev);
+
+ BUG_ON(mts == NULL);
+
free_irq(ASP_PENDATA_IRQ, mts);
free_irq(ASP_TOUCH_IRQ, mts);
- //input_free_device(mts->ts_idev);
+ iounmap(mts->mx1ts_mem);
+ release_mem_region(ASP_BASE_ADDR, 0x40);
+
+ input_free_device(mts->ts_idev);
kfree(mts);
printk("<1> Removing driver \tOK\n");