/* ************************************************************** */ /* ************************************************************** */ /* HRT PROBE */ /* ************************************************************** */ /* ************************************************************** */ /* hrt_probe - check that we have a device as the specified address. * Assume the memory region is already mapped. * The address has to be a virtual address mapped to the device I/O space. */ int hrt_probe(unsigned long addr) { unsigned char oldval1, oldval2, oldval3, newval2; unsigned int oldaddr; /* save the old values at the address */ oldval1 = readb(HRT_CONTROL_REG + addr); rmb(); oldaddr = readw(HRT_Y_LOW_REG + addr); rmb(); /* freeze the frame grabbing, immediately */ writeb(0x5B, HRT_CONTROL_REG + addr); wmb(); /* write a new value to the first byte in the first raster/row */ writew(0, HRT_Y_LOW_REG + addr); wmb(); oldval2 = readb(addr); rmb(); writeb(~oldval2, addr); wmb(); /* write oldval2 to the first byte of the next raster/row */ writew(1, HRT_Y_LOW_REG + addr); wmb(); oldval3 = readb(addr); rmb(); writeb(oldval2, addr); wmb(); /* read the value at the previous raster/row */ writew(0, HRT_Y_LOW_REG + addr); wmb(); newval2 = readb(addr); rmb(); /* restore the old values */ writeb(oldval2, addr); wmb(); writew(1, HRT_Y_LOW_REG + addr); wmb(); writeb(oldval3, addr); wmb(); writeb(oldaddr, HRT_Y_LOW_REG + addr); wmb(); writeb(oldval1, HRT_CONTROL_REG + addr); wmb(); return (newval2 == (unsigned char)~oldval2); }