* [ECOS] Device driver open & close @ 2008-08-26 4:49 Frank Pagliughi 2008-08-26 15:28 ` Andrew Lunn 0 siblings, 1 reply; 5+ messages in thread From: Frank Pagliughi @ 2008-08-26 4:49 UTC (permalink / raw) To: eCos Discussion Hey All, Is there a mechanism by which a device driver can be notified when the application opens or closes the device. For example, I have an LCD in my system, and I would like to turn it on when the application opens the device and turn it off when it gets closed. Then turn it back on again if it gets re-opened, etc. Thanks, Frank -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Device driver open & close 2008-08-26 4:49 [ECOS] Device driver open & close Frank Pagliughi @ 2008-08-26 15:28 ` Andrew Lunn 2008-08-26 21:20 ` Frank Pagliughi 0 siblings, 1 reply; 5+ messages in thread From: Andrew Lunn @ 2008-08-26 15:28 UTC (permalink / raw) To: Frank Pagliughi; +Cc: eCos Discussion On Mon, Aug 25, 2008 at 07:31:09PM -0400, Frank Pagliughi wrote: > Hey All, > > Is there a mechanism by which a device driver can be notified when the > application opens or closes the device. For example, I have an LCD in my > system, and I would like to turn it on when the application opens the > device and turn it off when it gets closed. Then turn it back on again > if it gets re-opened, etc. open() should result in the lookup function being called on the device. Close is a problem, since there is no device close function. You might be better using cyg_io_set_config() mechanism to turn it on and off. Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Device driver open & close 2008-08-26 15:28 ` Andrew Lunn @ 2008-08-26 21:20 ` Frank Pagliughi 2008-08-27 5:22 ` Frank Pagliughi 0 siblings, 1 reply; 5+ messages in thread From: Frank Pagliughi @ 2008-08-26 21:20 UTC (permalink / raw) To: Frank Pagliughi, eCos Discussion Andrew Lunn wrote: > On Mon, Aug 25, 2008 at 07:31:09PM -0400, Frank Pagliughi wrote: > >> Hey All, >> >> Is there a mechanism by which a device driver can be notified when the >> application opens or closes the device. For example, I have an LCD in my >> system, and I would like to turn it on when the application opens the >> device and turn it off when it gets closed. Then turn it back on again >> if it gets re-opened, etc. >> > > open() should result in the lookup function being called on the > device. > This gets called for each open? > Close is a problem, since there is no device close function. > > You might be better using cyg_io_set_config() mechanism to turn it on > and off. > This is unfortunate. For another example, the system will have the ability to power down the compact flash drive(s). Which order should the power down happen? flush() the buffers, then cyg_io_set_config() to power down the drive, *then* close() ? I assume you can't use the handle to set_config after the close(). Right? Frank -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Device driver open & close 2008-08-26 21:20 ` Frank Pagliughi @ 2008-08-27 5:22 ` Frank Pagliughi 2008-08-27 7:12 ` Andrew Lunn 0 siblings, 1 reply; 5+ messages in thread From: Frank Pagliughi @ 2008-08-27 5:22 UTC (permalink / raw) To: Frank Pagliughi, eCos Discussion Frank Pagliughi wrote: > > > Andrew Lunn wrote: >> On Mon, Aug 25, 2008 at 07:31:09PM -0400, Frank Pagliughi wrote: >> >>> Hey All, >>> >>> Is there a mechanism by which a device driver can be notified when >>> the application opens or closes the device. For example, I have an >>> LCD in my system, and I would like to turn it on when the >>> application opens the device and turn it off when it gets closed. >>> Then turn it back on again if it gets re-opened, etc. >>> >> >> open() should result in the lookup function being called on the >> device. >> > This gets called for each open? >> Close is a problem, since there is no device close function. >> >> You might be better using cyg_io_set_config() mechanism to turn it on >> and off. >> > This is unfortunate. For another example, the system will have the > ability to power down the compact flash drive(s). Which order should > the power down happen? > flush() the buffers, then cyg_io_set_config() to power down the > drive, *then* close() ? I assume you can't use the handle to > set_config after the close(). Right? > Oh, sorry, the disk drive is a bad example, and a whole different problem, I suppose. Maybe a drive can power up/down when its filesystem is mounted/unmounted? I'm just doing the OS port & device drivers for a board that has to really conserve power and thus turn devices off and on a lot. Someone else will write the application, so I'm trying to make the interface as simple and familiar as possible (therefore standard I/O api). It seems that the eCos device API assumes that devices will be initialized then stay on forever. So, any ideas are appreciated. Thanks, Frank -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Device driver open & close 2008-08-27 5:22 ` Frank Pagliughi @ 2008-08-27 7:12 ` Andrew Lunn 0 siblings, 0 replies; 5+ messages in thread From: Andrew Lunn @ 2008-08-27 7:12 UTC (permalink / raw) To: Frank Pagliughi; +Cc: eCos Discussion >> This gets called for each open? Yes. Take a look at the code: io/fileio/current/src/devfs.cxx:dev_open() calls cyg_io_lookup() on the device. And then there is this comment: // // Look up the devtab entry for a named device and return its handle. // If the device is found and it has a "lookup" function, call that // function to allow the device/driver to perform any necessary // initializations. // Cyg_ErrNo cyg_io_lookup(const char *name, cyg_io_handle_t *handle) >>> You might be better using cyg_io_set_config() mechanism to turn it on >>> and off. >>> >> This is unfortunate. For another example, the system will have the >> ability to power down the compact flash drive(s). Which order should >> the power down happen? >> flush() the buffers, then cyg_io_set_config() to power down the >> drive, *then* close() ? I assume you can't use the handle to >> set_config after the close(). Right? File systems work differently. There you have a clean mount and unmount. So i would extend the mount and umount call to call the cyg_io_set_config() to power the device up/down. However you might have a problem with the partition table, > I'm just doing the OS port & device drivers for a board that has to > really conserve power and thus turn devices off and on a lot. Someone > else will write the application, so I'm trying to make the interface as > simple and familiar as possible (therefore standard I/O api). It seems > that the eCos device API assumes that devices will be initialized then > stay on forever. So, any ideas are appreciated. Well LCD devices don't always follow standard I/O. This is especially true if you are doing a windowing driver? Or is it plain text. And how is the driver structured? Maybe you maintain a frame buffer in local memory and blit it out to the LCD every so often? With the cyg_io_set_config() you can keep the frame buffer running all the time and use the cyg_io_set_config() to power up/down the LCD controller and start/stop blitting. Another cyg_io_set_config() would control the backlight etc. Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-27 5:22 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-08-26 4:49 [ECOS] Device driver open & close Frank Pagliughi 2008-08-26 15:28 ` Andrew Lunn 2008-08-26 21:20 ` Frank Pagliughi 2008-08-27 5:22 ` Frank Pagliughi 2008-08-27 7:12 ` Andrew Lunn
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).