From: Antonio Ospite Date: Sat, 27 Jul 2013 21:25:34 +0000 (+0200) Subject: Rename am7xxx_mode_switch to am7xxx-modeswitch X-Git-Tag: v0.1.4~10 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/9929ba27d2c28ef364ecdd7b27120f0fe7000a8c?ds=inline;hp=-c Rename am7xxx_mode_switch to am7xxx-modeswitch The new name matches more closely the name of the binary used in recent usb-modeswitch versions. --- 9929ba27d2c28ef364ecdd7b27120f0fe7000a8c diff --git a/README.asciidoc b/README.asciidoc index ef981d4..d11a92f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -44,8 +44,8 @@ manually with the command: --default-product 0x1101 \ --message-content 55534243087052890000000000000cff020000000000000000000000000000 -Alternatively, on systems where libusb works but 'usb_mode_switch' is not -easily available, the switch can be performed using the 'am7xxx_mode_switch' +Alternatively, on systems where libusb works but 'usb-modeswitch' is not +easily available, the switch can be performed using the 'am7xxx-modeswitch' example program from libam7xxx. Examples of devices based on AM7XXX are: @@ -91,7 +91,7 @@ All the needed files need to be in the same location: - 'libssp-0.dll' from MinGW; - - 'am7xxx_mode_switch.exe', 'libam7xxx.dll' and 'picoproj.exe' which can all + - 'am7xxx-modeswitch.exe', 'libam7xxx.dll' and 'picoproj.exe' which can all be built by following the instructions in the HACKING.asciidoc document from libam7xxx. @@ -109,7 +109,7 @@ for both the mass storage device and the display device: from now on the virtual CD-ROM can't be accessed anymore until the +USBSTOR+ Driver is restored. - - Run 'am7xxx_mode_switch.exe' + - Run 'am7xxx-modeswitch.exe' - When the new (display) device shows up, run Zadig and install the +WinUSB+ driver for it too. diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index a21e82c..c7ce4bb 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -3,7 +3,7 @@ find_package(Asciidoc) if(ASCIIDOC_FOUND) add_custom_target(manpages ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/am7xxx-play.1.txt -D ${DOC_OUTPUT_PATH}/man - COMMAND ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/am7xxx_mode_switch.1.txt -D ${DOC_OUTPUT_PATH}/man + COMMAND ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/am7xxx-modeswitch.1.txt -D ${DOC_OUTPUT_PATH}/man COMMAND ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/picoproj.1.txt -D ${DOC_OUTPUT_PATH}/man WORKING_DIRECTORY ${DOC_OUTPUT_PATH}/man COMMENT "Generating man pages with Asciidoc" VERBATIM @@ -18,7 +18,7 @@ if(ASCIIDOC_FOUND) install(FILES ${DOC_OUTPUT_PATH}/man/am7xxx-play.1 - ${DOC_OUTPUT_PATH}/man/am7xxx_mode_switch.1 + ${DOC_OUTPUT_PATH}/man/am7xxx-modeswitch.1 ${DOC_OUTPUT_PATH}/man/picoproj.1 DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/" COMPONENT manpages) diff --git a/doc/man/am7xxx-modeswitch.1.txt b/doc/man/am7xxx-modeswitch.1.txt new file mode 100644 index 0000000..20dfd29 --- /dev/null +++ b/doc/man/am7xxx-modeswitch.1.txt @@ -0,0 +1,57 @@ +AM7XXX-MODESWITCH(1) +===================== +:doctype: manpage + + +NAME +---- +am7xxx-modeswitch - change the operational mode of am7xxx based devices + + +SYNOPSIS +-------- +*am7xxx-modeswitch* + + +DESCRIPTION +----------- +am7xxx-modeswitch(1) is a minimal replacement of usb-modeswitch to use with +am7xxx devices (e.g. Acer C110 or Philips PPX projectors) to switch from the +mass storage device mode to the generic display mode. + +It is handy on systems where usb-modeswitch is not available, like Windows. + + +EXAMPLE OF USE +-------------- + +am7xxx-modeswitch + + +EXIT STATUS +----------- +*0*:: + Success + +*!0*:: + Failure (libusb error) + + +AUTHORS +------- +Antonio Ospite + + +RESOURCES +--------- +Main web site: + + +COPYING +------- +Copyright \(C) 2012 Antonio Ospite + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. diff --git a/doc/man/am7xxx_mode_switch.1.txt b/doc/man/am7xxx_mode_switch.1.txt deleted file mode 100644 index c8fb728..0000000 --- a/doc/man/am7xxx_mode_switch.1.txt +++ /dev/null @@ -1,57 +0,0 @@ -AM7XXX_MODE_SWITCH(1) -===================== -:doctype: manpage - - -NAME ----- -am7xxx_mode_switch - change the operational mode of am7xxx based devices - - -SYNOPSIS --------- -*am7xxx_mode_switch* - - -DESCRIPTION ------------ -am7xxx_mode_switch(1) is a minimal replacement of usb-modeswitch to use with -am7xxx devices (e.g. Acer C110 or Philips PPX projectors) to switch from the -mass storage device mode to the generic display mode. - -It is handy on systems where usb-modeswitch is not available, like Windows. - - -EXAMPLE OF USE --------------- - -am7xxx_mode_switch - - -EXIT STATUS ------------ -*0*:: - Success - -*!0*:: - Failure (libusb error) - - -AUTHORS -------- -Antonio Ospite - - -RESOURCES ---------- -Main web site: - - -COPYING -------- -Copyright \(C) 2012 Antonio Ospite - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 64f15c0..c77a812 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -62,16 +62,16 @@ if(BUILD_AM7XXX-PLAY) DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") endif() -# Build a simple usb_mode_switch clone for am7xxx devices -option(BUILD_AM7XXX_MODE_SWITCH "Build a simple usb_mode_switch clone for am7xxx devices" TRUE) -if(BUILD_AM7XXX_MODE_SWITCH) +# Build a simple usb-modeswitch clone for am7xxx devices +option(BUILD_am7xxx-modeswitch "Build a simple usbmode-switch clone for am7xxx devices" TRUE) +if(BUILD_am7xxx-modeswitch) find_package(libusb-1.0 REQUIRED) include_directories(${LIBUSB_1_INCLUDE_DIRS}) - add_executable(am7xxx_mode_switch am7xxx_mode_switch.c) - target_link_libraries(am7xxx_mode_switch ${LIBUSB_1_LIBRARIES}) - install(TARGETS am7xxx_mode_switch + add_executable(am7xxx-modeswitch am7xxx-modeswitch.c) + target_link_libraries(am7xxx-modeswitch ${LIBUSB_1_LIBRARIES}) + install(TARGETS am7xxx-modeswitch DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") endif() diff --git a/examples/am7xxx-modeswitch.c b/examples/am7xxx-modeswitch.c new file mode 100644 index 0000000..9942d81 --- /dev/null +++ b/examples/am7xxx-modeswitch.c @@ -0,0 +1,97 @@ +/* am7xxx-modeswitch - a simple usb-modeswitch for am7xxx devices + * + * Copyright (C) 2012 Antonio Ospite + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#define AM7XXX_STORAGE_VID 0x1de1 +#define AM7XXX_STORAGE_PID 0x1101 +#define AM7XXX_STORAGE_CONFIGURATION 1 +#define AM7XXX_STORAGE_INTERFACE 0 +#define AM7XXX_STORAGE_OUT_EP 0x01 + +static unsigned char switch_command[] = + "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00" + "\x0c\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + +int main(void) +{ + int ret; + int transferred; + libusb_device_handle *usb_device = NULL; + + unsigned int len; + + ret = libusb_init(NULL); + if (ret < 0) + goto out; + + libusb_set_debug(NULL, 3); + + usb_device = libusb_open_device_with_vid_pid(NULL, + AM7XXX_STORAGE_VID, + AM7XXX_STORAGE_PID); + if (usb_device == NULL) { + fprintf(stderr, "cannot open the device: %d.\n", errno); + ret = -errno; + goto out; + } + + if (libusb_kernel_driver_active(usb_device, AM7XXX_STORAGE_INTERFACE)) { + ret = libusb_detach_kernel_driver(usb_device, + AM7XXX_STORAGE_INTERFACE); + if (ret < 0) + fprintf(stderr, "Warning: cannot detach kernel driver.\n"); + } else { + fprintf(stderr, "kernel driver not active.\n"); + } + + ret = libusb_set_configuration(usb_device, AM7XXX_STORAGE_CONFIGURATION); + if (ret < 0) { + fprintf(stderr, "cannot set configuration.\n"); + goto out_libusb_close; + } + + ret = libusb_claim_interface(usb_device, AM7XXX_STORAGE_INTERFACE); + if (ret < 0) { + fprintf(stderr, "cannot claim interface.\n"); + goto out_libusb_close; + } + + len = sizeof(switch_command); + transferred = 0; + ret = libusb_bulk_transfer(usb_device, AM7XXX_STORAGE_OUT_EP, + switch_command, len, &transferred, 0); + if (ret != 0 || (unsigned int)transferred != len) { + fprintf(stderr, "ret: %d\ttransferred: %d (expected %u)\n", + ret, transferred, len); + goto out_libusb_release_interface; + } + + fprintf(stderr, "OK, command sent!\n"); + +out_libusb_release_interface: + libusb_release_interface(usb_device, AM7XXX_STORAGE_INTERFACE); +out_libusb_close: + libusb_close(usb_device); + usb_device = NULL; +out: + libusb_exit(NULL); + return ret; +} diff --git a/examples/am7xxx_mode_switch.c b/examples/am7xxx_mode_switch.c deleted file mode 100644 index 572586c..0000000 --- a/examples/am7xxx_mode_switch.c +++ /dev/null @@ -1,97 +0,0 @@ -/* am7xxx_mode_switch - a simple usb_mode_switch for am7xxx devices - * - * Copyright (C) 2012 Antonio Ospite - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#define AM7XXX_STORAGE_VID 0x1de1 -#define AM7XXX_STORAGE_PID 0x1101 -#define AM7XXX_STORAGE_CONFIGURATION 1 -#define AM7XXX_STORAGE_INTERFACE 0 -#define AM7XXX_STORAGE_OUT_EP 0x01 - -static unsigned char switch_command[] = - "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00" - "\x0c\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - -int main(void) -{ - int ret; - int transferred; - libusb_device_handle *usb_device = NULL; - - unsigned int len; - - ret = libusb_init(NULL); - if (ret < 0) - goto out; - - libusb_set_debug(NULL, 3); - - usb_device = libusb_open_device_with_vid_pid(NULL, - AM7XXX_STORAGE_VID, - AM7XXX_STORAGE_PID); - if (usb_device == NULL) { - fprintf(stderr, "cannot open the device: %d.\n", errno); - ret = -errno; - goto out; - } - - if (libusb_kernel_driver_active(usb_device, AM7XXX_STORAGE_INTERFACE)) { - ret = libusb_detach_kernel_driver(usb_device, - AM7XXX_STORAGE_INTERFACE); - if (ret < 0) - fprintf(stderr, "Warning: cannot detach kernel driver.\n"); - } else { - fprintf(stderr, "kernel driver not active.\n"); - } - - ret = libusb_set_configuration(usb_device, AM7XXX_STORAGE_CONFIGURATION); - if (ret < 0) { - fprintf(stderr, "cannot set configuration.\n"); - goto out_libusb_close; - } - - ret = libusb_claim_interface(usb_device, AM7XXX_STORAGE_INTERFACE); - if (ret < 0) { - fprintf(stderr, "cannot claim interface.\n"); - goto out_libusb_close; - } - - len = sizeof(switch_command); - transferred = 0; - ret = libusb_bulk_transfer(usb_device, AM7XXX_STORAGE_OUT_EP, - switch_command, len, &transferred, 0); - if (ret != 0 || (unsigned int)transferred != len) { - fprintf(stderr, "ret: %d\ttransferred: %d (expected %u)\n", - ret, transferred, len); - goto out_libusb_release_interface; - } - - fprintf(stderr, "OK, command sent!\n"); - -out_libusb_release_interface: - libusb_release_interface(usb_device, AM7XXX_STORAGE_INTERFACE); -out_libusb_close: - libusb_close(usb_device); - usb_device = NULL; -out: - libusb_exit(NULL); - return ret; -}